Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connection String,Hard code works, but reading ini file doesn't

Status
Not open for further replies.

cyberbiker

Programmer
Mar 16, 2001
431
0
0
US
When I hardcode the connection string, everything appears fine. But when I try to read the connection string from an ini file, the ODBC connection fails.

The following code works:

Defaulttype = dbUseODBC
Set dbconnection = OpenConnection("", dbDriverNoPrompt, False, "ODBC;dsn=LocalServer;database=testa;uid=tah;pwd=;""")

when I attempt to use this code:
Defaulttype = dbUseODBC
set dbconnection = OpenConnection(bfGetODBCConnect())
The connection fails.

bfGetODBCConnect() returns the connection string from an ini file.

When I set a watch, bfGetODBCConnect returns what appears to be an identical string (including spaces):

"", dbDriverNoPrompt, False,
"ODBC;dsn=LocalServer;database=testa;uid=tah;pwd=;"""

Anybody have any ideas what I am doing wrong? Terry (cyberbiker)
 
Are you sending a single string into a function that requires 4 input parameters?

I'm afraid it doesn't work that way. Perfection in engineering does not happen when there is nothing more to add. Rather it happens when there is nothing more to take away.
 
Oh Do I feel stupid!!!! Of course that is it.
Sorry to be so goofy. Thanks for the help Terry (cyberbiker)
 
Hi,

would I use this function:

bfGetODBCConnect()

if I want to replicate my Access/SQL-server app STRUCTURE, not data, in other locations? I need to connect to the person's server w/o hard-coding the connection string.

thanks!
christy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top