VB 怎么用ADO控件链接access数据库啊?
3个回答
展开全部
Public conn As ADODB.Connection
Set conn = New ADODB.Connection
conn.CursorLocation = adUseClient
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\*.mdb;Persist Security Info=True;Jet OLEDB:Database Password=*******"
conn.CommandTimeout = 30
conn.Open
如果数据库没有密码,database password=******那段就可以不要。
Set conn = New ADODB.Connection
conn.CursorLocation = adUseClient
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\*.mdb;Persist Security Info=True;Jet OLEDB:Database Password=*******"
conn.CommandTimeout = 30
conn.Open
如果数据库没有密码,database password=******那段就可以不要。
展开全部
dim cnn as new adodb.connection
dim rs as new adodb.recordset
cnn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\1.mdb
rs.open "(SQL查询语句)",cnn,1,3
(其他语句)
rs.close
cnn.close
dim rs as new adodb.recordset
cnn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\1.mdb
rs.open "(SQL查询语句)",cnn,1,3
(其他语句)
rs.close
cnn.close
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim myConn As New ADODB.Connection
Dim myRecord As New ADODB.Recordset
Set myConn = New ADODB.Connection
myConn.CursorLocation = adUseClient
myConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\data.mdb" & ";Persist Security Info=False"
If myRecord.State <> adStateClosed Then myRecord.Close
myRecord.Open "select * from data", myConn, adOpenKeyset, adLockOptimistic
如果是ADODC的方式就更简单:
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\data.mdb" & ";Persist Security Info=False"
Adodc1.RecordSource = "select * from data": Adodc1.Refresh
Dim myRecord As New ADODB.Recordset
Set myConn = New ADODB.Connection
myConn.CursorLocation = adUseClient
myConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\data.mdb" & ";Persist Security Info=False"
If myRecord.State <> adStateClosed Then myRecord.Close
myRecord.Open "select * from data", myConn, adOpenKeyset, adLockOptimistic
如果是ADODC的方式就更简单:
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\data.mdb" & ";Persist Security Info=False"
Adodc1.RecordSource = "select * from data": Adodc1.Refresh
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询