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

📄 form1.frm

📁 VB连接SQL实例,对初学者很有帮助,帮助大大滴有
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "使用Connection对象"
   ClientHeight    =   3090
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3090
   ScaleWidth      =   4680
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton CmdExit 
      Caption         =   "退           出"
      Height          =   495
      Left            =   960
      TabIndex        =   1
      Top             =   1560
      Width           =   2295
   End
   Begin VB.CommandButton CmdExecute 
      Caption         =   "实例化Connection对象"
      Height          =   495
      Left            =   960
      TabIndex        =   0
      Top             =   480
      Width           =   2295
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'定义一个名为conn的connection对象,好比是买了自来水管道
Dim conn As New ADODB.Connection
'定义字符串类型的连接串
Dim connstr As String
'单击实例化Connection对象按钮后的执行代码
Private Sub CmdExecute_Click()
 connstr = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=sa;Initial Catalog=db_student;Data Source = mynetserver"
 conn.ConnectionString = connstr
  '打开服务器上的水闸
  conn.Open connstr
 '中间的处理过程
 '......
 '关闭服务器的水闸
 conn.Close
 '撤销管道,释放系统资源
 Set conn = Nothing
 MsgBox "成功完成Connection对象的操作流程", , "成功提示"
End Sub
'单击退出按钮后的执行代码
Private Sub CmdExit_Click()
  Unload Me
End Sub

⌨️ 快捷键说明

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