请问错在那里?VB连接MSSQL
Dim CN As New ADODB.Connection
Dim Rs As New ADODB.Recordset
CN.Open "Provider=sqloledb.1;Data Source=jhd;Initial Catalog=agdhrlbm;User Id=sa;Password=; "
Rs.Open "select stksbal.branchid,zname.branchname,sum(stksbal.balqtyichguntilc) as jhd01,sum(stksbal.balqtyichgafterc) as jhd02,sum(stksbal.balqtyibegin) as jhd03 from stksbal,zname where stksbal.branchid=zname.branchid and workyymm= '0707 ' goup by stksbal.branchid,zname.branchname "
Set DataGrid1.DataSource = Rs
运行后报这个错误码:
实时错误 '-2147467259(80004005) ':
[DBNETLIB][Connectionopen(Connect()).] SQL server 不存在或拒绝访问
[解决办法]
Data Source=jhd; 这个就是Sql服务器.
你用ADO控件,生成一个串试试.在生成时,可以测试能不能连接数据源(SQL服务).
生成完了,再把Ado控件删除