📄 form3.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"
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "tabctl32.ocx"
Begin VB.Form Form3
Caption = "Form3"
ClientHeight = 5835
ClientLeft = 60
ClientTop = 450
ClientWidth = 8265
LinkTopic = "Form3"
ScaleHeight = 5835
ScaleWidth = 8265
StartUpPosition = 3 '窗口缺省
Begin MSAdodcLib.Adodc Adodc1
Align = 2 'Align Bottom
Height = 330
Left = 0
Top = 5505
Width = 8265
_ExtentX = 14579
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
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 TabDlg.SSTab SSTab1
Height = 5295
Left = 0
TabIndex = 0
Top = 240
Width = 8055
_ExtentX = 14208
_ExtentY = 9340
_Version = 393216
Tabs = 2
TabHeight = 520
TabCaption(0) = "学生基本信息"
TabPicture(0) = "Form3.frx":0000
Tab(0).ControlEnabled= -1 'True
Tab(0).Control(0)= "DataGrid1"
Tab(0).Control(0).Enabled= 0 'False
Tab(0).Control(1)= "Command1"
Tab(0).Control(1).Enabled= 0 'False
Tab(0).Control(2)= "Command2"
Tab(0).Control(2).Enabled= 0 'False
Tab(0).Control(3)= "Command3"
Tab(0).Control(3).Enabled= 0 'False
Tab(0).ControlCount= 4
TabCaption(1) = "学生成绩管理"
TabPicture(1) = "Form3.frx":001C
Tab(1).ControlEnabled= 0 'False
Tab(1).Control(0)= "Command6"
Tab(1).Control(1)= "Command5"
Tab(1).Control(2)= "Command4"
Tab(1).Control(3)= "DataGrid2"
Tab(1).ControlCount= 4
Begin VB.CommandButton Command6
Caption = "删除"
Height = 375
Left = -69360
TabIndex = 8
Top = 4560
Width = 2055
End
Begin VB.CommandButton Command5
Caption = "修改"
Height = 375
Left = -71760
TabIndex = 7
Top = 4560
Width = 1935
End
Begin VB.CommandButton Command4
Caption = "添加"
Height = 375
Left = -74400
TabIndex = 6
Top = 4560
Width = 2055
End
Begin MSDataGridLib.DataGrid DataGrid2
Height = 3495
Left = -74640
TabIndex = 5
Top = 720
Width = 7455
_ExtentX = 13150
_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
Begin VB.CommandButton Command3
Caption = "删除"
Height = 375
Left = 5640
TabIndex = 4
Top = 4560
Width = 2055
End
Begin VB.CommandButton Command2
Caption = "修改"
Height = 375
Left = 3240
TabIndex = 3
Top = 4560
Width = 1935
End
Begin VB.CommandButton Command1
Caption = "添加"
Height = 375
Left = 600
TabIndex = 2
Top = 4560
Width = 2055
End
Begin MSDataGridLib.DataGrid DataGrid1
Height = 3495
Left = 360
TabIndex = 1
Top = 720
Width = 7455
_ExtentX = 13150
_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
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim cn As New ADODB.Connection
Dim rs1 As New ADODB.Recordset
Dim rs2 As New ADODB.Recordset
Private Sub Command1_Click()
If Command1.Caption = "添加" Then
Command1.Caption = "保存"
rs1.MoveLast
DataGrid1.AllowUpdate = True
DataGrid1.AllowAddNew = True
Else
rs1.Update
DataGrid1.Refresh
Command1.Caption = "添加"
End If
End Sub
Private Sub Command2_Click()
If Command2.Caption = "修改" Then
Command2.Caption = "保存"
DataGrid1.AllowUpdate = True
Else
rs1.Update
DataGrid1.Refresh
Command2.Caption = "修改"
End If
End Sub
Private Sub Command3_Click()
rs1.Delete
End Sub
Private Sub Command4_Click()
If Command4.Caption = "添加" Then
Command4.Caption = "保存"
rs2.MoveLast
DataGrid2.AllowUpdate = True
DataGrid2.AllowAddNew = True
Else
rs2.Update
DataGrid2.Refresh
Command4.Caption = "添加"
End If
End Sub
Private Sub Command5_Click()
If Command5.Caption = "修改" Then
Command5.Caption = "保存"
DataGrid2.AllowUpdate = True
Else
rs2.Update
DataGrid2.Refresh
Command5.Caption = "修改"
End If
End Sub
Private Sub Command6_Click()
rs2.Delete
End Sub
Private Sub Form_Load()
Set cn = New ADODB.Connection
Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
cn.CursorLocation = adUseClient
cn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=学生信息管理;Data Source=MMM-573F8CEF18C;integrated security=sspi", , , -1
rs1.Open "select * from 学生信息表", cn, adOpenDynamic, adLockOptimistic, 1
Set DataGrid1.DataSource = rs1
rs2.Open "select * from 成绩表 ", cn, adOpenDynamic, adLockOptimistic, 1
Set DataGrid2.DataSource = rs2
DataGrid1.AllowAddNew = False
DataGrid1.AllowUpdate = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -