|
-
November 6th, 2004, 09:15 AM
#1
ODBC DB Path
Hello All,
Which is the function, that can give information on the database path accessed by a DSN?
Thanks & Regards
Ms. Rajmathi
-
November 6th, 2004, 10:37 AM
#2
Re: ODBC DB Path
Hi,
If this question belongs to VB then you can try this
Take the component - Microsoft ADO database control 6.0 on the form..
right click on the control and select properties...
in the General Tab, select 'Use Connection String' option..then
Click the Build Button to follow the procedure...
You can paste the connection string into the form directly and remove
the control from the form...
Praveen Jain
[email protected]
-
November 6th, 2004, 11:02 AM
#3
Re: ODBC DB Path
If you use the MS Access database (MDB) you can parse the ODBC connect string for "...;DBQ=\YourDatabasePath\YourDatabaseFile.mdb;..." substring.
Code:
CDatabase db;
db.Open("YourDSN");
CString s = db.GetConnect();
s.Find("DBQ=");
A.M.
My Latest Articles:
CCustomBitmapButton - An owner-draw button and a frame for the caption bar, in one class.
CCustomTabCtrl - A clone of the Excel tab sheet control.
-
November 8th, 2004, 01:29 AM
#4
Re: ODBC DB Path
Hello All,
Thanks for the reply, but what I'm looking at is to get the database path without establishing the connection.
Thanks & Regards,
Rajmathi
Ms. Rajmathi
-
November 8th, 2004, 12:49 PM
#5
Re: ODBC DB Path
In dbcore.cpp the CDatabase::GetDatabaseName() method makes a call to the following ODBC API function.
char szName[MAX_TNAME_LEN];
SWORD nResult;
RETCODE nRetCode;
nRetCode = ::SQLGetInfo(m_hdbc, SQL_DATABASE_NAME, szName, _countof(szName), &nResult));
In looking at this though this requires a connection also.
-
November 8th, 2004, 05:50 PM
#6
Re: ODBC DB Path
Perhaps from the DSN info itself?
Code:
HENV hEnv;
UCHAR tmpDSN[256];
SWORD tmpDSNLen = 255;
SWORD ResultLen;
UCHAR tmpDriver[256];
SWORD tmpDriverLen = 255;
SWORD ResultDescLen;
RETCODE ReturnCode = SQL_SUCCESS;
int count = m_dateCTL.GetCount();
char tmpDate[10];
ReturnCode = ::SQLAllocEnv(&hEnv);
if (SQL_SUCCESS == ReturnCode)
{
ReturnCode = ::SQLDataSources(hEnv, SQL_FETCH_FIRST, tmpDSN, tmpDSNLen, &ResultLen, tmpDriver, tmpDriverLen, &ResultDescLen);
while (SQL_SUCCESS == ReturnCode)
{
// look at info
ReturnCode = ::SQLDataSources(hEnv, SQL_FETCH_NEXT, tmpDSN, tmpDSNLen, &ResultLen, tmpDriver, tmpDriverLen, &ResultDescLen);
}
}
::SQLFreeEnv(hEnv);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|