Vb6.0 编一个自定义的函数保存在模块中,函数是连接数据库的信息,要求窗体可以调用模块中的函数连接。
连接数据库信息如下DimcnAsADODB.ConnectionDimstrcnAsStringDimrsAsNewADODB.RecordsetSetcn=NewADO...
连接数据库信息 如下
Dim cn As ADODB.Connection
Dim strcn As String
Dim rs As New ADODB.Recordset
Set cn = New ADODB.Connection
strcn = " driver={SQL Server};server=127.0.0.1;database=strike;uid=sa;pwd=123"
cn.Open strcn
Set rs = New ADODB.Recordset
rs.Open "users", cn, adOpenDynamic, adLockOptimistic 展开
Dim cn As ADODB.Connection
Dim strcn As String
Dim rs As New ADODB.Recordset
Set cn = New ADODB.Connection
strcn = " driver={SQL Server};server=127.0.0.1;database=strike;uid=sa;pwd=123"
cn.Open strcn
Set rs = New ADODB.Recordset
rs.Open "users", cn, adOpenDynamic, adLockOptimistic 展开
展开全部
'对数据库进行操作模块
'链接数据库
Public Sub AdoDataCnn()
Str_cnn = "Provider=Microsoft.Jet.OLEDB.4.0;PASSWORD=;user id=;Data Source=" & App.Path & "\test.mdb"
Set AdoCnn = New ADODB.Connection
AdoCnn.ConnectionString = Str_cnn
AdoCnn.Open
End Sub
'关闭数据库
Public Sub AdoDataCls()
AdoCnn.Close
Set AdoCnn = Nothing
End Sub
'链接数据库
Public Sub AdoDataCnn()
Str_cnn = "Provider=Microsoft.Jet.OLEDB.4.0;PASSWORD=;user id=;Data Source=" & App.Path & "\test.mdb"
Set AdoCnn = New ADODB.Connection
AdoCnn.ConnectionString = Str_cnn
AdoCnn.Open
End Sub
'关闭数据库
Public Sub AdoDataCls()
AdoCnn.Close
Set AdoCnn = Nothing
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询