Link to home
Start Free TrialLog in
Avatar of smoyano
smoyano

asked on

Creating odbc connection to Oracle with code

We are working on an Access 97 application that uses ODBC to connect Oracle 7.3 tables. The ODBC driver prompts the user for a login id and password, which creates a connection that endures for the entire session.

We will take the user id and password from another application to avoid having them login again.

Is there a way to create an application wide connection using code? I have tried creating a workspace and connection with odbcdirect, but am still prompted by the ODBC drivers used to attach the tables.
Avatar of tomook
tomook

Build your connect string in code, and tack on:
UID=TheUserName;PWD=ThePassWord;

So for a DSN-less connection, it would look something like:
"UID=TheUserName;PWD=ThePassWord;DRIVER={Oracle73};DATABASE=SomeTablespace;SERVER=ServerAlias.world;"

For a DSN connection:
"DSN=SomeDSN;UID=TheUserName;PWD=ThePassWord;"
Avatar of smoyano

ASKER

The answer does not explain how creating a connect string in code can override the prompt from the ODBC drivers used to attach the Oracle tables.

The question is not the syntax of the connect string, but overriding the prompt when the user tried to access data from the attached table.  ODBC direct won't work, because we are working with forms and bound controls.
Just a question here: I've never heard of an ODBC driver having its own code.  Maybe you mean Oracle is prompting for a password?

In these cases, what I have heard of people doing is writing the password to the ODBC.INI file, but be advised that is risky.  If you exit from the application without cleaning up the file, you leave the person's ID and password where it is very easy to get at. Hope this helps clarify.
Avatar of smoyano

ASKER

Thanks for the clarification kaldrich. I do mean that the ODBC driver is promting us for a password and login id.

Bearing in mind your warning about security, could writing the login id and password to the odbc.ini file override the login prompt from the odnbc driver?

Thanks much for your time and help.
ASKER CERTIFIED SOLUTION
Avatar of coffeeshop
coffeeshop
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial