VB连接SQL问题
我用VB6连接一个远程的SQL数据库,用ADO连接的,现在我在窗体上又建了一个DataGrid,我想用DataGrid中连接这个远程数据库中的某一个表怎么办?如远程数据库...
我用VB6连接一个远程的SQL数据库,用ADO连接的,现在我在窗体上又建了一个DataGrid,我想用DataGrid中连接这个远程数据库中的某一个表怎么办?
如远程数据库地址192.168.161.11
数据库名称为:TJJSXM
其中要连接的表为:accept_tbl 展开
如远程数据库地址192.168.161.11
数据库名称为:TJJSXM
其中要连接的表为:accept_tbl 展开
展开全部
引用
Microsoft ActiveX Data Objects 2.8 Library
Microsoft ActiveX Data Objects Recordset 2.8 Library
Public conn_user As ADODB.Connection
Public rs As ADODB.Recordset
Set conn_user = New ADODB.Connection
conn_user.ConnectionString = "Provider=sqloledb;Data Source=192.168.161.11;Initial Catalog=TJJSXM;User Id=sa;Password=sa;"
conn_user.ConnectionTimeout = 5
conn_user.Open
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open "select * from accept_tbl ", conn_user, adOpenDynamic, adLockOptimistic
Set DataGrid1.DataSource = rs
Microsoft ActiveX Data Objects 2.8 Library
Microsoft ActiveX Data Objects Recordset 2.8 Library
Public conn_user As ADODB.Connection
Public rs As ADODB.Recordset
Set conn_user = New ADODB.Connection
conn_user.ConnectionString = "Provider=sqloledb;Data Source=192.168.161.11;Initial Catalog=TJJSXM;User Id=sa;Password=sa;"
conn_user.ConnectionTimeout = 5
conn_user.Open
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open "select * from accept_tbl ", conn_user, adOpenDynamic, adLockOptimistic
Set DataGrid1.DataSource = rs
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询