adolink.frm

来自「vb数据库编程资料」· FRM 代码 · 共 65 行

FRM
65
字号
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   1125
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   5250
   LinkTopic       =   "Form1"
   ScaleHeight     =   1125
   ScaleWidth      =   5250
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command2 
      Caption         =   "建立到jiaoxueDSN的连接"
      Height          =   495
      Left            =   2760
      TabIndex        =   1
      Top             =   240
      Width           =   2295
   End
   Begin VB.CommandButton Command1 
      Caption         =   "建立到SQLPubsDSN的连接"
      Height          =   495
      Left            =   120
      TabIndex        =   0
      Top             =   240
      Width           =   2415
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim CnA As New ADODB.Connection
Dim ReA As New ADODB.Recordset
Dim CnB As New ADODB.Connection
Dim ReB As New ADODB.Recordset
Private Sub Command1_Click()
  Dim Cnastring As String
  Cnastring = "DSN=SQLpubs;uid=sa;pwd=tongaihong"   'SQL DSN数据源连接字符串
  With CnA
     .connectionstring = Cnastring
     .ConnectionTimeout = 10
     .Open   '给连接的ConnectionString属性赋值,然后使用求带参数的Open方法打开连接
  End With
  MsgBox ("连接成功1")
  CnA.Close  '关闭连接
  CnA.Open "DSN=SQLpubs;uid=sa;pwd=tongaihong"
  MsgBox ("连接成功2")
End Sub

Private Sub Command2_Click()
  Dim Cnbstring As String
  Cnbstring = "DSN=jiaoxue;uid=;pwd=" 'Microsoft Access DSN数据源连接字符串
  With CnB
     .connectionstring = Cnbstring
     .ConnectionTimeout = 10
     .Open '给连接的ConnectionString属性赋值,然后使用求带参数的Open方法打开连接
  End With
  MsgBox ("连接成功3")
  CnB.Close  '关闭连接
  CnB.Open "DSN=jiaoxue;uid=;pwd="
  MsgBox ("连接成功4")
End Sub

⌨️ 快捷键说明

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