Tech Support > Microsoft Windows > Development Resources > Absolute Path for ODBC connection string
Absolute Path for ODBC connection string
Posted by magix on May 22nd, 2008


Hi,

I have:
CDatabase db;
CString sDriver = "MICROSOFT ACCESS DRIVER (*.mdb)";
CString sDsn;
CString sFile = "c:\\mydb.mdb";

// Build ODBC connection string
sDsn.Format("ODBC;DRIVER={%s};DSN='';PWD=12345;DBQ =%s",sDriver,sFile);

May I ask how to specify an absolute path of mdb file, instead of putting a
full directory path, ie c:\mydb.mdb ?

the application exe will be at the same directory as the mdb file.

Thanks.

Regards,
Magix



Posted by Scott McPhillips [MVP] on May 23rd, 2008


"magix" <magix@asia.com> wrote in message
news:48359b26$1_1@news.tm.net.my...

I have no idea what you think the difference is between an absolute path and
a full directory path???

Nevertheless, you seem to be under the impression that an ODBC DSN is a
file. It is not. What you have to do is call SQLConfigDataSource to
establish a DSN name and associate it with an mdb file. Then use the DSN
name in the connection string.

--
Scott McPhillips [VC++ MVP]


Posted by magix on May 23rd, 2008


On May 23, 8:21*am, "Scott McPhillips [MVP]" <org-dot-mvps-at-
scottmcp> wrote:


Sorry, i used wrong wording. absolute path = full path.
I should mean relative path.
the application will open the db file at the directory (wherever) of
where the application exe resides.
application might be at c:\abc\, or at c:\def\ , or other directory
etc. the db file will always together with exe at the same directory

Posted by magix on May 23rd, 2008


On May 23, 9:06*am, magix <mag...@gmail.com> wrote:
Maybe I will just GetCurrentPath() fo the application.


Similar Posts