VB之Adodc控件连接数据库
(2019-03-26 16:04:17)
标签:
vb
adoc
Access 数据库
如:
With Adodc1
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=E:\DB1.mdb;Persist Security Info=False"
.RecordSource = "select * from 数据表"
.CommandType = adCmdText
.Refresh
End With
其中 Data Source 中指定的数据库文件要用绝对路径及文件名称
如果是 SQL数据库,更换一下连接字符串就 可以了。
With Adodc1
.ConnectionString = "Provider=SQLOLEDB.1;Persist Security
Info=True;
User ID=sa; Password=; Data Source =服务器名;
Initial Catalog=数据库名;
.RecordSource = "select * from 数据表"
.CommandType = adCmdText
.Refresh
End With
分享: