Connect to Sybase from Excel

Posted on 2002-07-15
Last Modified: 2008-03-04

I need some example code to connect to Sybase from Excel 97 or 2000 and make some simple queries.  I know SQL so there is no problem there and I used to program in VB 4 but those days were more DAO than ADO.  However from what I can find ADO is better for Sybase.  I found this code:

Dim ad as ADODB.Connection

set ad=New ADODB.Connection
Let ad.ConnectionString= "ODBC;DSN=" & DatabaseName & ";UID=" & 
UserName & ";PWD=" & UserPassword

But I get an error at Dim ad... as if the ADODB object is not installed or not accesable from VBA.  The for the Sybase part I found this:

"Last, but not least in my mind and definitely no performance slouch is to use the ODBC driver but bypass ADO's default mechanism for connecting to ODBC drivers. Basically if you connect with standard syntax ODBC syntax, like: "Driver={Sybase System 11};PWD=vbguru;UID=gelbro;DB=dictionary;servername=SYBPRD_DEV" and so on, you'll be speeding along. "


In the section on Sybase 11.x, Im using 11.033.

If some one can throw these togeather and help me make it work I would appreciate it.  Do I maybe need to have VB installed?  I want this XLS to be distributable (See My Question:  Batch Reports With Dynamic Charts? )

Thanks for the help.

Question by:guadalupe
  • 3
  • 2
LVL 12

Expert Comment

by:James Elliott
ID: 7156520
It sounds like you know what your talking about so excuse this response if you have already thought of it!!!

Have you ticked your ADO references in the VB editor??

Goto tools/references and tick the ADO library.



Author Comment

ID: 7157751
No problem jell, and the response is actually yes and no.  I went to check the reference but the only one I found which related to ADO was: Microsoft ADO Ext. 2.5 for DDL and Security

Didn't seem like what I wanted but yes I had it checked anyway and I still got the error above.  I donde have just a plain ADO Lib.  Should it be there?

LVL 12

Expert Comment

by:James Elliott
ID: 7158875
I've just had a look into some of the projects that I've done and I think if you check the 'OLE Automation' reference then that should install the ADO library.


Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.


Author Comment

ID: 7160414
OLE Automation is checked, but thanks for the suggestion!

Accepted Solution

tommybak earned 500 total points
ID: 7166085
In references look for Microsoft ActiveX Data Object 2,5 library.
regards Tommy

Author Comment

ID: 7170135
That did it, thank you. Jell, think I was a little slow on the uptake.  If you need points, tell me and I'll repost to give you your cred!

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Introduction Perhaps more familiar to developers who primarily use VBScript than to developers who tend to work only with Microsoft Office and Visual Basic for Applications (VBA), the Dictionary is a powerful and versatile class, and is useful …
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

831 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