Solved

DNS-less connection to Sybase

Posted on 1998-11-17
7
640 Views
Last Modified: 2013-12-25
I'm trying to make a DSN-less RDO connection to a Sybase SQL server. I can make the connection fine with a user DSN, but I want to make the connection without the DSN. Here's what I'm using...

strConnection = "UID=user;PWD=password;" _
    & "DATABASE=dbname;" _
    & "SERVER=SYBASE;" _
    & "DRIVER={Sybase System 11};DSN='';"
Set rdoCon = rdoEnv.OpenConnection(dsName:="", _
    prompt:=rdDriverNoPrompt, _
    Connect:=strConnection)

If I set the prompt to rdDriverPrompt, I get a dialog box that allows me to enter 'SYBASE' as the server, and the connection is made - my query won't run (not sure why - says no cursor is open), but it does connect. However, running the connection above with rdDriverNoPrompt(which is how it should run) results in an error - [Intersolv][ODBC SQL Server Driver] Invalid attribute in connection string: SERVER. - which sounds like a syntax error, but that format is straight from the help file. Anyone have any ideas? Thanks.
0
Comment
Question by:Joe33
7 Comments
 

Author Comment

by:Joe33
ID: 1497684
Edited text of question
0
 
LVL 3

Expert Comment

by:vmano
ID: 1497685
is your server/computer name SYBASE? if not, try this:
change the parameter SERVER to the server/computer name where the database is.you can find the computer name in controlpanel->network->identification tab. and also, you don't have to specify the DSN parameter.

let me know if this helps
vmano
0
 

Author Comment

by:Joe33
ID: 1497686
The server is named 'SYBASE'...if I run the connect string with an rdDriverPrompt, I can enter the server name (SYBASE) and it will make a connection. For some reason, it won't connect when it's an rdDriverNoPrompt, I get the 'invalid attribute: SERVER' when it runs. Thanks again.
0
Industry Leaders: 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!

 
LVL 3

Expert Comment

by:vmano
ID: 1497687
try this:
Dim cn As New rdoConnection
Dim qd As New rdoQuery

cn.Connect = "uid=USER;pwd=PASSWORD;server=SYBASE;" _
    & "driver={Sybase System 11};database=DBNAME;DSN='';"
cn.cursordriver = rdUseOdbc
cn.EstablishConnection rdDriverNoprompt
debug.print cn.Connect

Set qd.ActiveConnection = cn

let me know if this helps
vmano
0
 

Expert Comment

by:Coates
ID: 1497688
You can specify the Server Name etc while setting up the ODBC under control panel. This means that you only have to reference the DSN name in your code and the predefined ODBC will do the rest:
e.g:
Dim cn as rdoConnection;
cn.Connect = "DSN=dsnname;UID=uid;PWD=password";
cn.CursorDriver = rdUseODBC
cn.EstablishConnection rdDriverNoPrompt

This should connect using the server and driver details specified in control panel and then connect without showing a dialog box, which is what i think you want.
Hope this works,
0
 

Author Comment

by:Joe33
ID: 1497689
I've gotten it to work with a DSN, I'm trying to avoid setting up a DSN on every client machine by using a DSN-less connection.

Thanks
0
 
LVL 1

Accepted Solution

by:
pmteixeira earned 200 total points
ID: 1497690
Hi Joe,

if you still have this problem, why don't you set the prompt to rdDriverPrompt and normally enter your code, adding this line to it:

       MsgBox rdoCon.Connect

This way you can see the connect string that was used (and this one must work)! Like you, I believe that your error is a syntax error due to the driver you're using!
But after having a correct ConnectString you may paste it into your code and use rdDriverNoPrompt.

Hope this helps,

PMT
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBS file using code from 2nd file (txt or vbs) 4 47
Excel - Save a copy of work book 13 91
Access Object Property from VBA Module in Excel 2010 2 40
MsgBox 4 71
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

749 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