vbscript SQL Server连接 [英] vbscript SQL server connection

查看:175
本文介绍了vbscript SQL Server连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下脚本连接到远程sql服务器

I use the following script to connect to a remote sql server

Dim sServer,sDataBaseName ,sConn,oConn,oRS
Dim sUserName,sPassWord 
 
sServer = "test.test.com,1057\testtable\test"
sDataBaseName = "DM_dbname"
sUserName = "username"
sPassWord = "password"
 
''sConn="provider=sqloledb;data source=" & sServer & ";initial catalog=" & sDataBaseName & ";"
sConn="DRIVER={SQL Server};SERVER=" & sServer & ";DATABASE=" & sDataBaseName & ";Encrypt=Yes;"
Set oConn = CreateObject("ADODB.Connection")
oConn.CommandTimeout = 36000
oConn.Open sConn, sUserName, sPassWord

Set FetchData = CreateObject("ADODB.Recordset")
FetchData.open "SELECT COUNT (*) FROM [DM_Reports].[dbo].[Preferences]", oconn
While Not FetchData.eof 
          msgbox(FetchData.Preferences)
FetchData.movenext
Wend



我收到此错误



I get this error

Microsoft OLE DB Provider for ODBC Drivers (19, 1) : [Microsoft][ODBC SQL Server Driver][DBNETLIB]SSL Security error
ADODB.Recordset (22, 1) : The connection cannot be used to perform this operation. It is either closed or invalid in this context.


推荐答案

基于错误消息,很可能是加密.尝试将加密"设置为否"以测试是否是这个原因.
似乎这可能与MDAC有关.有几篇文章可以重新安装MDAC 2.8可能会有所帮助.有关错误的详细信息,请参见: http://support.microsoft.com/kb/839428 [
Based on the error message, it''s quite likely the encryption. Try setting Encrypt to no to test if that''s the reason.

Seems that this may be MDAC related. There are several posts that re-installing MDAC 2.8 could help. On quite close bug reference: http://support.microsoft.com/kb/839428[^]


这篇关于vbscript SQL Server连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆