📄 frmtablehouse.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmTableHouse
BorderStyle = 1 'Fixed Single
Caption = "以表格显示房间资料"
ClientHeight = 4350
ClientLeft = 45
ClientTop = 330
ClientWidth = 9945
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 4350
ScaleWidth = 9945
Begin VB.Frame Frame1
Caption = "选择排序方式"
Height = 615
Left = 2760
TabIndex = 1
Top = 3720
Width = 4455
Begin VB.CommandButton cmdOrder
Caption = "排 序"
Height = 255
Left = 3000
TabIndex = 3
Top = 240
Width = 1215
End
Begin VB.ComboBox Combo1
Height = 300
ItemData = "frmTableHouse.frx":0000
Left = 1080
List = "frmTableHouse.frx":001C
TabIndex = 2
Text = "Combo1"
Top = 240
Width = 1575
End
Begin VB.Label Label1
Caption = "排序方式"
Height = 255
Left = 120
TabIndex = 4
Top = 240
Width = 855
End
End
Begin MSAdodcLib.Adodc Adodc1
Height = 330
Left = 360
Top = 3840
Visible = 0 'False
Width = 1695
_ExtentX = 2990
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 2
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 3
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "DSN=XiaoQu"
OLEDBString = ""
OLEDBFile = ""
DataSourceName = "XiaoQu"
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "House"
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin MSDataGridLib.DataGrid DataGrid1
Height = 3495
Left = 0
TabIndex = 0
Top = 120
Width = 9855
_ExtentX = 17383
_ExtentY = 6165
_Version = 393216
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
End
Attribute VB_Name = "frmTableHouse"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs_house As New ADODB.Recordset
Dim rs_order As New ADODB.Recordset
Private Sub cmdOrder_Click()
'排序显示全部数据,而不是查询结果数据
Dim sql As String
If queryhouse = False Then
If rs_order.State = adStateOpen Then
rs_order.Close
End If
sql = "select * from House order by " & Combo1.Text
rs_order.CursorLocation = adUseClient
rs_order.Open sql, conn, adOpenStatic, adLockOptimistic
'设置DataGrid1的数据源
Set DataGrid1.DataSource = rs_order
DataGrid1.Refresh
'因查询而调用,只显示符合查询的数据
ElseIf queryhouse = True Then
If rs_order.State = adStateOpen Then
rs_order.Close
End If
sql = "select * from House " & sqlqh & " order by " & Combo1.Text
rs_order.CursorLocation = adUseClient
rs_order.Open sql, conn, adOpenStatic, adLockOptimistic
Set DataGrid1.DataSource = rs_order
DataGrid1.Refresh
End If
End Sub
Private Sub Form_activate()
Dim X0 As Long
Dim Y0 As Long
'让窗体居中
X0 = Screen.Width
Y0 = Screen.Height
X0 = (X0 - Me.Width) / 2
Y0 = (Y0 - Me.Height) / 2
Me.Move X0, Y0
'设置网格不可写
DataGrid1.AllowAddNew = False
DataGrid1.AllowDelete = False
DataGrid1.AllowUpdate = False
Combo1.ListIndex = 0
'显示全部数据,而不是查询结果数据
Dim sql As String
If queryhouse = False Then
sql = "select * from House order by 房间编号"
rs_house.CursorLocation = adUseClient
rs_house.Open sql, conn, adOpenStatic, adLockOptimistic
'设置DataGrid1的数据源
Set DataGrid1.DataSource = rs_house
DataGrid1.Refresh
'因查询而调用,只显示符合查询的数据
ElseIf queryhouse = True Then
sql = "select * from House " & sqlqh & " order by 房间编号"
rs_house.CursorLocation = adUseClient
rs_house.Open sql, conn, adOpenStatic, adLockOptimistic
Set DataGrid1.DataSource = rs_house
DataGrid1.Refresh
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
'使网格的数据源转向空的Adodc控件,否则有可能无法关闭
Set DataGrid1.DataSource = Adodc1
DataGrid1.Refresh
rs_house.Close
If rs_order.State = adStateOpen Then
rs_order.Close
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -