Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


connecting to sybase with ado in vba

Posted on 2003-03-10
Medium Priority
Last Modified: 2011-04-14
I'm trying to figure out how to connect to sybase with ado. So far I haven't been able to find many good resources online, as most tutorials seem to be for Access databases. I'm using Sybase ASE 12.x, and vba for Excel 2000. I've got the ADO 2.7 library. I know my driver and OLE DB provider. I also know the db name, port, host. But I keep getting error when trying to create and access the recordset.  

Dim conn
Set conn = CreateObject("ADODB.Connection")

conn.Provider = "the sybase provider"
conn.Open "Driver={the driver};" & _
          "Database=dbName;" & _
           "Srvr=someServer;" & _
           "Uid=someID;" & _

Set rs = CreateObject("ADODB.recordset")
rs.Open "select userID from table1, conn"

For Each x In rs.fields
   MsgBox x

I dont think I set up the Open connection correctly, I'm not even sure what kind of string is supposed to go in there (what are all the connection properties that need to be set). Is there even an ADO reference library anywhere online??
Thanks in advance for any insights provided.
Question by:otiemot

Accepted Solution

cmurugavel earned 120 total points
ID: 8163956

Follow the below coding, it should work since it's working on my production system :

'database variables
Dim dbSAP As New ADODB.Connection
Dim rsSAP As New ADODB.Recordset
Dim sProc As String
Public wsSAP As Worksheet

    sPass = "passwd"
    sUserId = "login"
    sDataSourceName = "database name"
Sub ConnectToDatabase()
    'set logon details:
    Debug.Print "Connecting to database"
    On Error GoTo Login_Error
    If dbSAP.State = 0 Then
        dbSAP.Open sDataSourceName, sUserId, sPass, 0
    End If

    Exit Sub
     MsgBox "Could not connect to the database. Please contact the System Administrator."
End Sub

LVL 29

Expert Comment

ID: 11208918

Do you still need help with this, or can it be closed?

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Dropbox has a relatively new feature called Smart Sync.  This feature allows Dropbox Professional (not plus) and Dropbox Business (if enabled) users to store information in Dropbox WITHOUT storing any files on their computer.
The article explains the process to deploy a Self-Service password reset portal I developed a few years ago. Hopefully, it will prove useful to someone.  Any comments, bug reports etc. are welcome...
Loops Section Overview
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question