Click here to Skip to main content
Rate this: bad
good
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 = "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 9-Apr-11 3:00am
Edited 9-Apr-11 3:03am
Slacker00775.8K
v2
Comments
Cool Smith at 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
good
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: http://support.microsoft.com/kb/839428[^]
  Permalink  
v2
Comments
Cool Smith at 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 at 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 at 9-Apr-11 12:11pm
   
how do i ping a mysl server?
which firewalls mine or on the server?
Mika Wendelius at 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 at 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)

  Print Answers RSS
0 OriginalGriff 190
1 Jochen Arndt 155
2 PIEBALDconsult 150
3 Afzaal Ahmad Zeeshan 120
4 DamithSL 115
0 OriginalGriff 5,695
1 DamithSL 4,591
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 9 Apr 2011
Copyright © CodeProject, 1999-2014
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