EXCEL VBA 连接SQL SERVER错误问题 10
代码如下:DimcnAsNewADODB.ConnectionDimstrCnAsStringDimstrSQLAsStringstrCn="Provider=sqlol...
代码如下:
Dim cn As New ADODB.ConnectionDim strCn As StringDim strSQL As StringstrCn = "Provider=sqloledb;Server=localhost;Database=RK;Uid=sa;Pwd=;Integrated Security=true;"cn.Open strCncn.Close已经在工具-引用(R)中勾选了Microsoft ActiveX Data Objects 2.8 Library。
这是我在网上看到的代码和做法,都按部就班的做了,可现在还是报错,如图:
请高手们帮个忙,小弟感激不尽! 展开
Dim cn As New ADODB.ConnectionDim strCn As StringDim strSQL As StringstrCn = "Provider=sqloledb;Server=localhost;Database=RK;Uid=sa;Pwd=;Integrated Security=true;"cn.Open strCncn.Close已经在工具-引用(R)中勾选了Microsoft ActiveX Data Objects 2.8 Library。
这是我在网上看到的代码和做法,都按部就班的做了,可现在还是报错,如图:
请高手们帮个忙,小弟感激不尽! 展开
2个回答
展开全部
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
Dim strCn As String
Dim strSQL As String
strCn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;PWD=;Initial Catalog=rk;Data Source=localhos;"
cn.Open strCn
cn.Close
Set cn = New ADODB.Connection
Dim strCn As String
Dim strSQL As String
strCn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;PWD=;Initial Catalog=rk;Data Source=localhos;"
cn.Open strCn
cn.Close
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询