用VB怎么编写用ADODC连接到其他服务器上的SQL数据库?
我想在请问一下,就是用ADODC连接到SQL数据了,查询到数据了,我怎么把查询到的数据赋值给一个变量?...
我想在请问一下,就是用ADODC连接到SQL数据了,查询到数据了,我怎么把查询到的数据赋值给一个变量?
展开
展开全部
1:VB编写的登录局域网内的sql2000数据库服务器代码
Private Sub Command1_Click()
'首先引用Microsoft Activex Data Objects 2.x Library
Dim objcon As New ADODB.Connection
Dim objrs As New ADODB.Recordset
Dim strConn As String
strConn = "Provider=SQLOLEDB.1;User ID=sa;password=密码;Initial Catalog=数据库名称;Data Source=本机IP地址(192.168.1.136)"
objcon.Open strConn
'strConn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;password=hNXQF222;Initial Catalog=database;Data Source=192.168.1.136"
'objcon.Open "Provider=sqloledb.1;user id=sa;password=hNXQF222;Initial Catalog=Northwind;Data Source="
objrs.Open "select * from Orders", objcon, 3, 1
'在部件中添加DataGrid控件
Set DataGrid1.DataSource = objrs
End Sub
2:用SETFACTORY打包可以打包数据库!
Private Sub Command1_Click()
'首先引用Microsoft Activex Data Objects 2.x Library
Dim objcon As New ADODB.Connection
Dim objrs As New ADODB.Recordset
Dim strConn As String
strConn = "Provider=SQLOLEDB.1;User ID=sa;password=密码;Initial Catalog=数据库名称;Data Source=本机IP地址(192.168.1.136)"
objcon.Open strConn
'strConn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;password=hNXQF222;Initial Catalog=database;Data Source=192.168.1.136"
'objcon.Open "Provider=sqloledb.1;user id=sa;password=hNXQF222;Initial Catalog=Northwind;Data Source="
objrs.Open "select * from Orders", objcon, 3, 1
'在部件中添加DataGrid控件
Set DataGrid1.DataSource = objrs
End Sub
2:用SETFACTORY打包可以打包数据库!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询