Hello All,
Which is the function, that can give information on the database path accessed by a DSN?
Thanks & Regards
Printable View
Hello All,
Which is the function, that can give information on the database path accessed by a DSN?
Thanks & Regards
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]
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=");
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
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.
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);