📄 depquery.frm
字号:
VERSION 5.00
Object = "{CE671F01-259E-40DA-92FE-95803E2ECBB5}#1.0#0"; "SmartXPButton.ocx"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form depquery
BackColor = &H00E7DFE7&
Caption = "院系查询"
ClientHeight = 4635
ClientLeft = 60
ClientTop = 450
ClientWidth = 5970
Icon = "depquery.frx":0000
LinkTopic = "Form3"
ScaleHeight = 4635
ScaleWidth = 5970
StartUpPosition = 2 '屏幕中心
Begin VB.Frame Frame1
BackColor = &H00E7DFE7&
Caption = "查询条件"
Height = 1575
Left = 600
TabIndex = 2
Top = 2880
Width = 5175
Begin VB.TextBox Text2
Height = 390
Left = 1440
TabIndex = 1
Top = 840
Width = 1455
End
Begin VB.TextBox Text1
Height = 375
Left = 1440
TabIndex = 0
Top = 360
Width = 1455
End
Begin SmartXPButton.XpButton XpButton3
Height = 495
Left = 3360
TabIndex = 3
Top = 840
Width = 1335
_ExtentX = 2355
_ExtentY = 873
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Caption = "关闭(&C)"
PictureSmoothBackColor= 15460844
ButtonPicture = "depquery.frx":0A02
End
Begin SmartXPButton.XpButton XpButton4
Height = 495
Left = 3360
TabIndex = 4
Top = 240
Width = 1335
_ExtentX = 2355
_ExtentY = 873
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Caption = "查询(&S)"
PictureSmoothBackColor= 15460844
ButtonPicture = "depquery.frx":1414
End
Begin VB.Label Label14
BackStyle = 0 'Transparent
Caption = "院系名称:"
Height = 375
Left = 480
TabIndex = 6
Top = 960
Width = 855
End
Begin VB.Label Label15
BackStyle = 0 'Transparent
Caption = "院系编号:"
Height = 255
Left = 480
TabIndex = 5
Top = 480
Width = 855
End
End
Begin MSDataGridLib.DataGrid DataGrid1
Height = 2130
Left = 840
TabIndex = 7
Top = 600
Width = 4095
_ExtentX = 7223
_ExtentY = 3757
_Version = 393216
AllowUpdate = 0 'False
BackColor = 16777215
ForeColor = -2147483642
HeadLines = 1
RowHeight = 18
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
Begin VB.Label label1
BackStyle = 0 'Transparent
Caption = "院系信息查询"
BeginProperty Font
Name = "隶书"
Size = 21.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000002&
Height = 495
Left = 1560
TabIndex = 8
Top = 0
Width = 2895
End
End
Attribute VB_Name = "depquery"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim sql As String
Dim sql1 As String
Dim sql2 As String
Dim WithEvents MyRs As ADODB.Recordset
Attribute MyRs.VB_VarHelpID = -1
Dim myrs1 As ADODB.Recordset
Dim myconn As ADODB.Connection
Private Sub Form_Load()
Set myconn = New ADODB.Connection
myconn.ConnectionString = "driver={SQL Server};" & _
"server=(local);uid=sa;pwd=;database=student_info"
myconn.Open
'***** 使用Recordset对象的Open方法创建记录集 *****
'myrs.Open "student", myconn, adOpenStatic, adLockOptimistic, adCmdTable
Set MyRs = New ADODB.Recordset
MyRs.ActiveConnection = myconn
MyRs.Source = "department"
MyRs.CursorLocation = adUseClient
MyRs.CursorType = adOpenStatic
MyRs.Open , , , adLockOptimistic
Set DataGrid1.DataSource = MyRs
DataGrid1.Columns(0).Caption = "院系编号"
DataGrid1.Columns(1).Caption = "院系名称"
DataGrid1.Columns(0).Width = 800
DataGrid1.Columns(1).Width = 1400
End Sub
Private Sub XpButton3_Click()
MyRs.Close
myconn.Close
Unload Me
End Sub
Private Sub XpButton4_Click()
sql = "select * from department where 1=1"
If Trim(Text1.Text) = "" Then
sql1 = " "
Else
sql1 = "and id='" & Trim(Text1.Text) & "'"
End If
If Trim(Text2.Text) = "" Then
sql2 = " "
Else
sql2 = "and name='" & Trim(Text2.Text) & "'"
End If
sql = sql & sql1 & sql2
Set MyRs = New ADODB.Recordset
MyRs.ActiveConnection = myconn
MyRs.Source = sql
MyRs.CursorLocation = adUseClient
MyRs.CursorType = adOpenStatic
MyRs.Open , , , adLockOptimistic
Set DataGrid1.DataSource = MyRs
DataGrid1.Columns(0).Caption = "院系编号"
DataGrid1.Columns(1).Caption = "院系名称"
DataGrid1.Columns(0).Width = 800
DataGrid1.Columns(1).Width = 1400
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -