Click here to Skip to main content
12,956,606 members (68,169 online)
Rate this:
Please Sign up or sign in to vote.
I use the following script to connect to a remote sql server

Dim sServer,sDataBaseName ,sConn,oConn,oRS
Dim sUserName,sPassWord 
sServer = ",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") "SELECT COUNT (*) FROM [DM_Reports].[dbo].[Preferences]", oconn
While Not FetchData.eof 

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 9-Apr-11 2:00am
Updated 9-Apr-11 2:03am
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

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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:[^]
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
Mika 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?
Mika 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,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)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,869
CHill60 3,550
Maciej Los 3,302
ppolymorphe 2,080
Jochen Arndt 1,973

Advertise | Privacy | Mobile
Web01 | 2.8.170525.1 | Last Updated 9 Apr 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100