Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
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.

what could be the problem?
Posted
Updated 9-Apr-11 2:03am
v2
Comments
Cool Smith 9-Apr-11 12:05pm    
when i set encrypt to no, i get timeout error
------------------------
Microsoft OLE DB Provider for ODBC Drivers (19, 1) : [Microsoft][ODBC SQL Server Driver]Timeout expired

1 solution

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[^]
 
Share this answer
 
v2
Comments
Cool Smith 9-Apr-11 8:35am    
when i set encrypt to no, i get timeout error
------------------------
Microsoft OLE DB Provider for ODBC Drivers (19, 1) : [Microsoft][ODBC SQL Server Driver]Timeout expired
Wendelius 9-Apr-11 8:52am    
Seems that the connection cannot be made at all. Few things you could try:
- ping the remote server to see that the overall connectivity works.
- check that there are no firewalls blocking the connection (disable for test if you have any)
- include the username (uid=???) and password (pwd=????) to the connection string
- check the server name. If you're using a named instance, ensure that the instance name is specified
Cool Smith 9-Apr-11 12:11pm    
how do i ping a mysl server?
which firewalls mine or on the server?
Wendelius 9-Apr-11 12:45pm    
For pinging, open the command prompt, write ping serveripaddress
Both firewalls can cause problems. If you're using for example Windows 7 then it's firewall may be blocking the traffic to port 1433 to the remote server (which is the default port of Sql Server)
Cool Smith 25-Apr-11 5:23am    
when i ping like this "ping host:port" i get a bad parameter. how do i ping a particular port. here is the connection string am using now.

"Data Source=www.host.com,57919;Integrated Security=True;User ID=myusername;Password=mypassword;Encrypt=True;TrustServerCertificate=True"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900