📄 moddatabase.bas
字号:
Attribute VB_Name = "modDatabase"
'**************************************************
' Author : Vivek Patel
' Email : vivek_patel9@rediffmail.com
' Website : www.vivekpatel.cjb.net
'**************************************************
'Note : To Copy and Paste this code require to
'add reference => follow the instructions
'1> Project Menu => Reference
'2> Add Microsoft ActiveX Data Object Library 2.1
Option Explicit
Public cn As New ADODB.Connection
Public rs As New ADODB.Recordset
'Make Database Connection
Public Sub main()
Dim path As String
path = App.path & "\company.mdb"
cn.ConnectionString = "provider=Microsoft.Jet.OLEDB.3.51;data source=" & path & ";"
cn.Open
If cn.State = adStateClosed Then
MsgBox "Connection Error", vbCritical, "Error!"
End
Else
Debug.Print "Connection Object Created"
cn.CursorLocation = adUseClient
End If
'Setting Initial data for recordset
rs.Open "Select * from companies", cn, adOpenDynamic, adLockOptimistic
Debug.Print "Recordset Object Created"
Call Form1.Show
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -