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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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.


Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.


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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

688 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