form1.frm

来自「数字查找系统 vb环境开发 界面做的非常好 是vb学习的绝佳素材 this vb」· FRM 代码 · 共 45 行

FRM
45
字号
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "连接Access"
   ClientHeight    =   1695
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5760
   LinkTopic       =   "Form1"
   ScaleHeight     =   1695
   ScaleWidth      =   5760
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command1 
      Caption         =   "连接Access数据库"
      Height          =   495
      Left            =   960
      TabIndex        =   0
      Top             =   600
      Width           =   3735
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Command1_Click()
 Dim con As Object
 On Error GoTo ErrHandle
    Set con = New ADODB.Connection
    Dim strcon As String
    strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\data.mdb;Persist Security Info=False;"
    con.Open strcon
    If con Is Nothing Then
     MsgBox "连接失败,请你检查数据库路径!"
    Else
      MsgBox "连接成功!"
    End If
    Exit Sub
ErrHandle:
   MsgBox "连接失败,请你检查数据库路径!"

End Sub
 

⌨️ 快捷键说明

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