vb中如何才能与SQL2000 连接
1个回答
展开全部
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
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询