📄 form2.frm
字号:
VERSION 5.00
Begin VB.Form Formupdate
Caption = "update"
ClientHeight = 6525
ClientLeft = 60
ClientTop = 420
ClientWidth = 9000
LinkTopic = "Form1"
Picture = "Form2.frx":0000
ScaleHeight = 16312.5
ScaleMode = 0 'User
ScaleWidth = 15000
StartUpPosition = 3 '窗口缺省
Begin VB.PictureBox MSF1
Height = 5535
Left = 5160
ScaleHeight = 5475
ScaleWidth = 4035
TabIndex = 8
Top = 360
Width = 4095
End
Begin VB.CommandButton Command2
Caption = "删除修改"
Height = 735
Left = 2880
TabIndex = 7
Top = 3720
Width = 2175
End
Begin VB.CommandButton Command1
BackColor = &H80000001&
Caption = "确定"
Height = 735
Left = 120
TabIndex = 6
Top = 3720
Width = 2055
End
Begin VB.TextBox Text3
Height = 975
Left = 2280
TabIndex = 5
Top = 1800
Width = 2535
End
Begin VB.TextBox Text2
Height = 855
Left = 2280
TabIndex = 3
Top = 840
Width = 2535
End
Begin VB.TextBox Text1
Height = 735
Left = 2280
TabIndex = 1
Top = 0
Width = 2535
End
Begin VB.Label Label3
Alignment = 1 'Right Justify
BackColor = &H8000000D&
Caption = "请输入修改后的成绩:"
Height = 255
Left = 120
TabIndex = 4
Top = 1920
Width = 1815
End
Begin VB.Label Label2
Alignment = 1 'Right Justify
BackColor = &H8000000D&
Caption = "输入要修改的成绩的课程号"
Height = 255
Left = 0
TabIndex = 2
Top = 1200
Width = 2175
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
BackColor = &H8000000D&
Caption = "请输入学生学号"
Height = 255
Left = 720
TabIndex = 0
Top = 240
Width = 1335
End
End
Attribute VB_Name = "Formupdate"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public printstr As String
Public Sub showtitle()
MSF1.Clear
Dim i As Integer
With MSF1
.Cols = 14
.TextMatrix(0, 1) = "学号"
.TextMatrix(0, 2) = "课程名"
.TextMatrix(0, 3) = "成绩"
.ColWidth(0) = 0
.ColWidth(1) = 1000
.ColWidth(2) = 800
.ColWidth(3) = 1000
.FixedRows = 1
For i = 1 To 3
.ColAlignment(i) = 0
Next i
.FillStyle = flexFillSingle
.Col = 0
.Row = 0
.RowSel = 1
.ColSel = .Cols - 1
.CellAlignment = 4
.Row = 1
End With
End Sub
Public Sub showdata()
Dim j As Integer
Dim i As Integer
Dim myConn As New ADODB.Connection
mySQL = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=student;"
mySQL = mySQL + "Initial Catalog=学生信息管理系统;"
myConn.ConnectionString = mySQL
myConn.Open
Dim mrc As ADODB.Recordset
Set mrc = New ADODB.Recordset
Set mrc = myConn.Execute(printstr)
If mrc.EOF = False Then
mrc.MoveFirst
With MSF1
.Rows = 50
.Row = 1
Do While Not mrc.EOF
.Rows = .Rows + 1
For i = 1 To mrc.Fields.Count
.TextMatrix(.Row, i) = mrc.Fields(i - 1)
Next i
.Row = .Row + 1
mrc.MoveNext
Loop
End With
End If
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
MSF1.Clear
End Sub
Private Sub Command1_Click()
Dim txtsql As String
Dim txtsql2 As String
Dim myConn As New ADODB.Connection
mySQL = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=student;"
mySQL = mySQL + "Initial Catalog=学生信息管理系统;"
myConn.ConnectionString = mySQL
myConn.Open
Dim aa As Integer
txtsql = ""
txtsql2 = ""
If (Trim(Text1.Text) = "" Or Trim(Text2.Text) = "") Then
ss = MsgBox("你必须要输入学生学号和课程名才能进行更新!", , " 警告")
Text1.SetFocus
Exit Sub
End If
If (Trim(Text3.Text) = "" Or Trim(Text3.Text) < 0) Then
ss = MsgBox("你输入的成绩不合法!", , " 警告")
Text3.Text = ""
Exit Sub
End If
txtsql = "select * from studentcourse where studentcourse.学生学号='" & Trim(Text1.Text) & "' and studentcourse.课程号='" & Trim(Text2.Text) & "'"
Dim mrc As ADODB.Recordset
Set mrc = myConn.Execute(txtsql)
If mrc.EOF = True Then
zzz = MsgBox("对不起,此学生没有修读该课程或成绩并未添加!", vbOKOnly, "注意")
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Exit Sub
End If
txtsql2 = "update studentcourse set studentcourse.成绩=" & Trim(Text3.Text) & " where studentcourse.学生学号=(select 学生学号 from student where 学生学号='" & Trim(Text1.Text) & "' )and studentcourse.课程号=(select 课程号 from course where 课程号='" & Trim(Text2.Text) & "') "
Set mrc = myConn.Execute(txtsql2)
zzz = MsgBox("修改成功", vbOKOnly, "完成")
printstr = txtsql
find = True
Formupdate.showtitle
Formupdate.showdata
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -