?? stuquery.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"
Object = "{C932BA88-4374-101B-A56C-00AA003668DC}#1.1#0"; "MSMASK32.OCX"
Begin VB.Form stuquery
BackColor = &H00E7DFE7&
Caption = "學生信息查詢"
ClientHeight = 7245
ClientLeft = 60
ClientTop = 450
ClientWidth = 9000
Icon = "stuquery.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 7245
ScaleWidth = 9000
StartUpPosition = 2 '屏幕中心
Begin VB.Frame Frame1
BackColor = &H00E7DFE7&
Caption = "查詢條件"
Height = 2295
Left = 600
TabIndex = 9
Top = 4680
Width = 7815
Begin VB.TextBox Text1
Height = 375
Left = 840
TabIndex = 0
Top = 360
Width = 1455
End
Begin VB.TextBox Text2
Height = 375
Left = 840
TabIndex = 2
Top = 1080
Width = 1455
End
Begin VB.TextBox Text3
Height = 375
Left = 5880
TabIndex = 6
Top = 360
Width = 1455
End
Begin VB.ComboBox Combo1
Height = 300
Left = 840
Style = 2 'Dropdown List
TabIndex = 4
Top = 1680
Width = 1215
End
Begin VB.ComboBox Combo2
Height = 300
Left = 3600
Style = 2 'Dropdown List
TabIndex = 1
Top = 360
Width = 1215
End
Begin VB.ComboBox Combo3
Height = 300
Left = 3600
Style = 2 'Dropdown List
TabIndex = 3
Top = 960
Width = 1215
End
Begin SmartXPButton.XpButton XpButton3
Height = 495
Left = 6000
TabIndex = 10
Top = 1560
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 = "關(guān)閉(&C)"
PictureSmoothBackColor= 15460844
ButtonPicture = "stuquery.frx":0A02
End
Begin SmartXPButton.XpButton XpButton4
Height = 495
Left = 6000
TabIndex = 11
Top = 960
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 = "stuquery.frx":1414
End
Begin MSMask.MaskEdBox txtbirth
Height = 390
Left = 3600
TabIndex = 5
Top = 1560
Width = 1215
_ExtentX = 2143
_ExtentY = 688
_Version = 393216
MaxLength = 10
Mask = "####-##-##"
PromptChar = "_"
End
Begin VB.Label Label15
BackStyle = 0 'Transparent
Caption = "學號:"
Height = 255
Left = 240
TabIndex = 18
Top = 480
Width = 495
End
Begin VB.Label Label14
BackStyle = 0 'Transparent
Caption = "姓名:"
Height = 375
Left = 240
TabIndex = 17
Top = 1200
Width = 495
End
Begin VB.Label Label13
BackStyle = 0 'Transparent
Caption = "性別:"
Height = 495
Left = 240
TabIndex = 16
Top = 1800
Width = 495
End
Begin VB.Label Label12
BackStyle = 0 'Transparent
Caption = "班級編號:"
Height = 495
Left = 2640
TabIndex = 15
Top = 480
Width = 1215
End
Begin VB.Label Label11
BackStyle = 0 'Transparent
Caption = "院系編號:"
Height = 255
Left = 2640
TabIndex = 14
Top = 1080
Width = 1215
End
Begin VB.Label Label10
BackStyle = 0 'Transparent
Caption = "生日:"
Height = 495
Left = 3000
TabIndex = 13
Top = 1680
Width = 1215
End
Begin VB.Label Label9
BackStyle = 0 'Transparent
Caption = "籍貫:"
Height = 255
Left = 5280
TabIndex = 12
Top = 480
Width = 495
End
End
Begin MSDataGridLib.DataGrid DataGrid1
Height = 3690
Left = 360
TabIndex = 8
Top = 840
Width = 8295
_ExtentX = 14631
_ExtentY = 6509
_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 = 2760
TabIndex = 7
Top = 120
Width = 2895
End
End
Attribute VB_Name = "stuquery"
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 sql3 As String
Dim sql4 As String
Dim sql5 As String
Dim sql6 As String
Dim sql7 As String
Dim WithEvents MyRs As ADODB.Recordset
Attribute MyRs.VB_VarHelpID = -1
Dim myrs1 As ADODB.Recordset
Dim myrs2 As ADODB.Recordset
Dim str As String
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方法創(chuàng)建記錄集 *****
'myrs.Open "student", myconn, adOpenStatic, adLockOptimistic, adCmdTable
Set MyRs = New ADODB.Recordset
MyRs.ActiveConnection = myconn
MyRs.Source = "student"
MyRs.CursorLocation = adUseClient
MyRs.CursorType = adOpenStatic
MyRs.Open , , , adLockOptimistic
Set DataGrid1.DataSource = MyRs
DataGrid1.Columns(0).Caption = "學號"
DataGrid1.Columns(1).Caption = "姓名"
DataGrid1.Columns(2).Caption = "性別"
DataGrid1.Columns(3).Caption = "班級編號"
DataGrid1.Columns(4).Caption = "院系編號"
DataGrid1.Columns(5).Caption = "生日"
DataGrid1.Columns(6).Caption = "籍貫"
DataGrid1.Columns(3).Width = 1100
DataGrid1.Columns(5).Width = 1200
DataGrid1.Columns(6).Width = 1000
str = "select ID from DEPARTMENT"
Set myrs1 = myconn.Execute(str)
While Not myrs1.EOF
Combo3.AddItem myrs1!ID
myrs1.MoveNext
Wend
str = "select ID from CLASS"
Set myrs2 = myconn.Execute(str)
While Not myrs2.EOF
Combo2.AddItem myrs2!ID
myrs2.MoveNext
Wend
Combo2.AddItem ""
Combo3.AddItem ""
Combo1.AddItem "男"
Combo1.AddItem "女"
Combo1.AddItem ""
End Sub
Private Sub XpButton3_Click()
MyRs.Close
myconn.Close
Unload Me
End Sub
Private Sub XpButton4_Click()
If Val(txtBirth.Text) <> 0 Then
If Not IsDate(txtBirth.Text) Then
MsgBox "生日不是有效日期,請重新輸入!", vbInformation, "提示"
txtBirth.SetFocus
txtBirth.Text = "____-__-__"
Exit Sub
End If
End If
sql = "select * from student 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
If Trim(Combo1.Text) = "" Then
sql3 = " "
Else
sql3 = "and sex='" & Trim(Combo1.Text) & "'"
End If
If Trim(Combo2.Text) = "" Then
sql4 = " "
Else
sql4 = "and class='" & Trim(Combo2.Text) & "'"
End If
If Trim(Combo3.Text) = "" Then
sql5 = " "
Else
sql5 = "and department='" & Trim(Combo3.Text) & "'"
End If
If Trim(Text3.Text) = "" Then
sql7 = " "
Else
sql7 = "and native_place='" & Trim(Text3.Text) & "'"
End If
sql = sql & sql1 & sql2 & sql3 & sql4 & sql5 & sql7
Set MyRs = New ADODB.Recordset
MyRs.ActiveConnection = myconn
MyRs.Source = sql
MyRs.CursorLocation = adUseClient
MyRs.CursorType = adOpenStatic
MyRs.Open , , , adLockOptimistic
If Val(txtBirth.Text) <> 0 Then
MyRs.Filter = "birthday='" & txtBirth.Text & "'"
End If
Set DataGrid1.DataSource = MyRs
DataGrid1.Columns(0).Caption = "學號"
DataGrid1.Columns(1).Caption = "姓名"
DataGrid1.Columns(2).Caption = "性別"
DataGrid1.Columns(3).Caption = "班級編號"
DataGrid1.Columns(4).Caption = "院系編號"
DataGrid1.Columns(5).Caption = "生日"
DataGrid1.Columns(6).Caption = "籍貫"
DataGrid1.Columns(3).Width = 1100
DataGrid1.Columns(5).Width = 1200
DataGrid1.Columns(6).Width = 1000
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -