📄 form9.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"
Begin VB.Form 修改学生记录
Caption = "修改学生记录"
ClientHeight = 6225
ClientLeft = 60
ClientTop = 345
ClientWidth = 7890
LinkTopic = "Form1"
ScaleHeight = 6225
ScaleWidth = 7890
StartUpPosition = 3 'Windows Default
Begin VB.Frame Frame1
Caption = "请输入需要修改学生信息的学号"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 5775
Left = 240
TabIndex = 0
Top = 240
Width = 7455
Begin VB.CommandButton Command3
Caption = "搜索"
Height = 375
Left = 3720
TabIndex = 4
Top = 360
Width = 1095
End
Begin VB.TextBox Text1
Height = 375
Left = 840
TabIndex = 3
Top = 360
Width = 2535
End
Begin VB.CommandButton Command1
Caption = "确 定 修 改"
Height = 495
Left = 120
TabIndex = 2
Top = 4680
Width = 2175
End
Begin VB.CommandButton Command2
Caption = "退 出"
Height = 495
Left = 5040
TabIndex = 1
Top = 4680
Width = 2175
End
Begin MSAdodcLib.Adodc Adodc1
Height = 495
Left = 120
Top = 4080
Width = 6975
_ExtentX = 12303
_ExtentY = 873
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 1
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;Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=学生管理;Data Source=HELL-2660D7069B"
OLEDBString = "Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=学生管理;Data Source=HELL-2660D7069B"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "select * from xsxx"
Caption = ""
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin MSDataGridLib.DataGrid DataGrid1
Bindings = "form9.frx":0000
Height = 3015
Left = 240
TabIndex = 5
Top = 840
Width = 6855
_ExtentX = 12091
_ExtentY = 5318
_Version = 393216
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
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
Caption = "学 号:"
Height = 375
Left = 120
TabIndex = 7
Top = 480
Width = 735
End
Begin VB.Label Label2
Caption = "请在显示的记录里修改需要改动的项^_^"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 5160
TabIndex = 6
Top = 360
Width = 1935
End
End
End
Attribute VB_Name = "修改学生记录"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim i As Integer
Private Sub Command1_Click()
If i = 0 Then
Adodc1.Recordset.Update
Adodc1.Refresh
MsgBox "学生记录修改成功", vbOKOnly, "学生记录修改成功"
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
'以下代码用于出错处理
Dim MsgText As String
Dim sMeg As String
If Text1.Text = "" Then
sMeg = "学号不能为空"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
Text1.SetFocus
Exit Sub
Else
If Not IsNumeric(Text1.Text) Then
MsgBox "请输入数字!", vbOKOnly + vbExclamation, "警告"
Text1.SetFocus
Text1.Text = ""
Exit Sub
End If
End If
Adodc1.RecordSource = "select * from xsxx where 学号 = " & Text1.Text & ""
Adodc1.Refresh
If Adodc1.Recordset.BOF And Adodc1.Recordset.EOF Then
MsgBox "学号不存在!请重新输入!", vbOKOnly, "错误"
Text1.Text = ""
Exit Sub
Else
Adodc1.Refresh
If DataGrid1.Row < 0 Then
MsgBox "学号不存在!请重新输入!", vbOKOnly, "错误"
Text1.Text = ""
Exit Sub
Else
i = 0
End If
End If
End Sub
Private Sub Form_Load()
'连接数据库
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sSQL As String
Dim sOut As String
Dim Count As Integer
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
' Set properties of the Connection.
cn.ConnectionString = "DSN=成绩查询;UID=sa;PWD=sa;"
cn.ConnectionTimeout = 30
cn.Open
Adodc1.ConnectionString = "DSN=成绩查询;UID=sa;PWD=sa;"
Adodc1.RecordSource = "select * from xsxx"
Set DataGrid1.DataSource = Adodc1
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -