📄 form6.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form Form6
BackColor = &H00FFFF00&
Caption = "Form6"
ClientHeight = 3150
ClientLeft = 60
ClientTop = 390
ClientWidth = 4680
LinkTopic = "Form6"
ScaleHeight = 3150
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text6
Height = 375
Left = 1440
TabIndex = 15
Top = 2520
Width = 1095
End
Begin MSAdodcLib.Adodc Adodc1
Height = 495
Left = 2760
Top = 2520
Width = 1935
_ExtentX = 3413
_ExtentY = 873
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 = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=a;Data Source=a10"
OLEDBString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=a;Data Source=a10"
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 VB.CommandButton Command4
Caption = "查询"
Height = 495
Left = 3240
TabIndex = 13
Top = 1320
Width = 1215
End
Begin VB.CommandButton Command3
Caption = "删除"
Height = 495
Left = 3240
TabIndex = 12
Top = 720
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "增加"
Height = 495
Left = 3240
TabIndex = 11
Top = 120
Width = 1215
End
Begin VB.TextBox Text5
Height = 375
Left = 1440
TabIndex = 10
Top = 2040
Width = 1095
End
Begin VB.TextBox Text4
Height = 375
Left = 1440
TabIndex = 8
Top = 1560
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "退出"
Height = 495
Left = 3240
TabIndex = 6
Top = 1920
Width = 1215
End
Begin VB.TextBox Text3
Height = 375
Left = 1440
TabIndex = 5
Top = 1080
Width = 1095
End
Begin VB.TextBox Text2
Height = 375
Left = 1440
TabIndex = 4
Top = 600
Width = 1095
End
Begin VB.TextBox Text1
Height = 375
Left = 1440
TabIndex = 3
Top = 120
Width = 1095
End
Begin VB.Label Label6
BackColor = &H00FFFF00&
Caption = "学生号输入"
ForeColor = &H000000FF&
Height = 255
Left = 360
TabIndex = 14
Top = 2520
Width = 975
End
Begin VB.Label Label5
BackColor = &H00FFFF00&
Caption = "学生姓名"
ForeColor = &H000000FF&
Height = 255
Left = 360
TabIndex = 9
Top = 2040
Width = 735
End
Begin VB.Label Label4
BackColor = &H00FFFF00&
Caption = "学生号"
ForeColor = &H000000FF&
Height = 255
Left = 480
TabIndex = 7
Top = 120
Width = 735
End
Begin VB.Label Label3
BackColor = &H00FFFF00&
Caption = "学分"
ForeColor = &H000000FF&
Height = 255
Left = 480
TabIndex = 2
Top = 1560
Width = 615
End
Begin VB.Label Label2
BackColor = &H00FFFF00&
Caption = "成绩"
ForeColor = &H000000FF&
Height = 255
Left = 480
TabIndex = 1
Top = 1080
Width = 615
End
Begin VB.Label Label1
BackColor = &H00FFFF00&
Caption = "课程号"
ForeColor = &H000000FF&
Height = 255
Left = 480
TabIndex = 0
Top = 600
Width = 735
End
End
Attribute VB_Name = "Form6"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim conn As New ADODB.Connection
Dim add As New ADODB.Command
Dim rst As New ADODB.Recordset
Private Sub Command1_Click()
Form6.Hide
Form9.Show
End Sub
Private Sub Command2_Click()
Dim one As String
Set rst.ActiveConnection = conn
one = "select * from xuekecheng "
rst.Open one
If Text1.Text <> "" And Text2.Text <> "" And Text3.Text <> "" And Text4.Text <> "" And Text5.Text <> "" Then
rst.AddNew
rst.Fields("学生号") = CInt(Text1.Text)
rst.Fields("课程号") = Text2.Text
rst.Fields("成绩") = Text3.Text
rst.Fields("学分") = Text4.Text
rst.Fields("学生名") = Text5.Text
rst.Update
MsgBox "ok"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Else
MsgBox "nothing"
End If
rst.Close
End Sub
Private Sub Command3_Click()
Dim one As String
Set rst.ActiveConnection = conn
If (Text6.Text = "") Then
MsgBox "在查询处填入你要删掉的记录的学生号"
GoTo end2
Else
one = "select*from xuekecheng where 学生号=" & CInt(Text6.Text)
End If
rst.Open one
If rst.EOF Then
MsgBox "nothing"
GoTo end1
End If
Text1.Text = rst.Fields("学生号")
Text2.Text = rst.Fields("课程号")
Text3.Text = rst.Fields("成绩")
Text4.Text = rst.Fields("学分")
Text5.Text = rst.Fields("学生名")
rst.Delete
rst.Update
end1:
rst.Close
end2:
End Sub
Private Sub Command4_Click()
Dim one As String
Set rst.ActiveConnection = conn
If (Text6.Text = "") Then
one = "select*from xuekecheng"
Else
one = "select*from xuekecheng where 学生号=" & CInt(Text6.Text)
End If
rst.Open one
If rst.EOF Then
MsgBox "nothing"
GoTo end1
End If
Text1.Text = rst.Fields("学生号")
Text2.Text = rst.Fields("课程号")
Text3.Text = rst.Fields("成绩")
Text4.Text = rst.Fields("学分")
Text5.Text = rst.Fields("学生名")
end1:
rst.Close
End Sub
Private Sub Form_Load()
Set conn = New ADODB.Connection
Set rst = New ADODB.Recordset
Set add = New ADODB.Command
rst.LockType = adLockOptimistic
rst.CursorType = adOpenKeyset
conn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=a"
conn.Open
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -