⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form2.frm

📁 数据库查询语言
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form2 
   Caption         =   "学生记录添加\删除"
   ClientHeight    =   5055
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   6405
   LinkTopic       =   "Form2"
   ScaleHeight     =   5055
   ScaleWidth      =   6405
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command2 
      Caption         =   "取消"
      Height          =   495
      Left            =   3240
      TabIndex        =   11
      Top             =   3600
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "确定"
      Height          =   495
      Left            =   1080
      TabIndex        =   10
      Top             =   3600
      Width           =   1215
   End
   Begin VB.TextBox Text4 
      Height          =   375
      Left            =   1200
      TabIndex        =   9
      Top             =   2520
      Width           =   1455
   End
   Begin VB.TextBox Text3 
      Height          =   375
      Left            =   4080
      TabIndex        =   8
      Top             =   1440
      Width           =   1335
   End
   Begin VB.ComboBox Combo1 
      Height          =   300
      ItemData        =   "Form2.frx":0000
      Left            =   1320
      List            =   "Form2.frx":000A
      TabIndex        =   7
      Top             =   1440
      Width           =   1335
   End
   Begin VB.TextBox Text2 
      Height          =   375
      Left            =   4080
      TabIndex        =   6
      Top             =   480
      Width           =   1335
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   1320
      TabIndex        =   5
      Top             =   480
      Width           =   1335
   End
   Begin VB.Label Label5 
      Caption         =   "系别:"
      Height          =   375
      Left            =   120
      TabIndex        =   4
      Top             =   2520
      Width           =   855
   End
   Begin VB.Label Label4 
      Caption         =   "年龄:"
      Height          =   375
      Left            =   3120
      TabIndex        =   3
      Top             =   1440
      Width           =   615
   End
   Begin VB.Label Label3 
      Caption         =   "性别:"
      Height          =   375
      Left            =   120
      TabIndex        =   2
      Top             =   1440
      Width           =   735
   End
   Begin VB.Label Label2 
      Caption         =   "姓名:"
      Height          =   255
      Left            =   3120
      TabIndex        =   1
      Top             =   480
      Width           =   735
   End
   Begin VB.Label Label1 
      Caption         =   "学号:"
      Height          =   255
      Left            =   240
      TabIndex        =   0
      Top             =   480
      Width           =   735
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False



Private Sub Command1_Click()
Dim sql As String
Dim a As String
sql = "select Sno from student where Sno='20060002'" '查询条件'
a = 20060002
If sql = a Then
MsgBox ("输入的学号相同!请从新输入")
Else

If Form1.cmdadd.Enabled = True Then
Form1.Adodc1.Recordset.AddNew '添加一条新记录
Else

Form1.Adodc1.Recordset.Update '将修改的记录保存在数据库中
End If
'将结果集相应的字段写到文本框中
Form1.Adodc1.Recordset.Fields("Sno") = Trim(Text1.Text)
Form1.Adodc1.Recordset.Fields("Sname") = Trim(Text2.Text)
Form1.Adodc1.Recordset.Fields("Ssex") = Trim(Combo1.Text)
Form1.Adodc1.Recordset.Fields("Sage") = CInt(Trim(Text3.Text))
Form1.Adodc1.Recordset.Fields("Sdept") = Trim(Text4.Text)
Text1.Text = ""
Text2.Text = ""
Combo1.Text = ""
Text3.Text = ""
Text4.Text = ""
End If
End Sub

Private Sub Command2_Click()
 Form2.Visible = False
Form1.CmdUpdate.Enabled = True
Form1.cmdadd.Enabled = True
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -