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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

connecting ti MS Access database without ODBC

Status
Not open for further replies.

swordfish1973

Technical User
Nov 6, 2003
13
IT
Hi all,
I need to connect to a MS Access from my C++ Builder 5 Project, without using the ODBC configuration window. This because I need to change the database file in runtime, and I can't access the file path from outside the ODBC manager.
I tried to create an alias, but it causes me a lot of errors while defining the configuration in the parameters.
Can someone help me please?
Thank you
Maurizio
PS I have the professional dedition and thus don't have the ADOexpress package
 
if you use ODBC API, you can use SQLDriverConnect instead of SQLConnect. SQLDriverConnect does not require databaase to be registered in ODBC.

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
thank you very much!
Could you show me more details about this connection (have almost zero experience on this....)
Cheers
Maurizio
 
is something like this:

HENV hEnv;
HDBC hDbc;
RETCODE rc;
int iOut;
char strOut[256];
char szDSN[256] = "driver={Microsoft Access Driver (*.mdb)};dbq=[c:\\db1.mdb];";

......
rc = SQLDriverConnect(hDbc, NULL, (unsigned char*)szDSN,
SQL_NTS, (unsigned char*)strOut, 255, (SQLSMALLINT*)&iOut, SQL_DRIVER_NOPROMPT);


Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
which files do I need to include to use SQLDriverConnect on my project?
 
thank you ion, but it gives me "Unresolved external...." when I compile with SQLDriverConnect....
 
don't forget to link with
odbc32.lib and odbccp32.lib

Ion Filipski
1c.bmp
 
sorry to bother you Ion, but now that I solved my linker problem, how should I work with the code you gave me? Do I need to include any object different from a TTable?
Thank you for your availability, you're being very helpful!
Cheers
Maurizio
 
sorry, but TTable is borland specific. I don't know what to do with TTable. What you using different kind of SQL*Connect is a connection(a HDBC). So, you should create a select statement and to execute it(you will use SQLPrepare/SQLBindColumn/SQLExecute). After that use SQLFetch to get data from the statement. What to do with data is up to you. Look in thread116-689078 to see more info. Any other what is borland specific I don't know.

Ion Filipski
1c.bmp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top