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

📄 addform.frm

📁 用VB6如何来连接最新的SQL2005数据库,在本例中有详细的代码参考!分享是一种快乐
💻 FRM
字号:
VERSION 5.00
Begin VB.Form AddForm 
   Caption         =   "添加窗体"
   ClientHeight    =   4425
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   6765
   LinkTopic       =   "Form1"
   ScaleHeight     =   4425
   ScaleWidth      =   6765
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command1 
      Caption         =   "添加数据"
      Height          =   615
      Left            =   5160
      TabIndex        =   3
      Top             =   120
      Width           =   1215
   End
   Begin VB.CommandButton btnClose 
      Caption         =   "关闭"
      Height          =   735
      Left            =   4800
      TabIndex        =   2
      Top             =   2760
      Width           =   1575
   End
   Begin VB.TextBox Text1 
      Height          =   495
      Left            =   1560
      TabIndex        =   1
      Text            =   "Text1"
      Top             =   120
      Width           =   3375
   End
   Begin VB.Label Label1 
      Caption         =   "学历:"
      Height          =   375
      Left            =   480
      TabIndex        =   0
      Top             =   240
      Width           =   1215
   End
End
Attribute VB_Name = "AddForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub btnClose_Click()
 '  End  '其实,End它是VB中关闭了所有窗体的命令
 Unload AddForm  'Unload + "你要关闭的窗体名或者(Me,即当前的窗体)"
 
 
    
End Sub

Private Sub Command1_Click()

    '连接数据库 并且创建连接对象 Connection
   Dim conn
   Set conn = New ADODB.Connection
   conn.Open "dsn=myDB", "sa", "sa456"
    
   
   Set rs = New Recordset
   
   sql = "insert into 学历(xueli) values ('" & Me.Text1.Text & "' )"
   
   Set rs = conn.Execute(sql)
   
   MsgBox "恭喜恭喜,数据添加成功!"
   

End Sub

Private Sub Form_Load()
   Me.Text1.Text = ""
   
End Sub

⌨️ 快捷键说明

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