How will I know that DSN is not pointing to any database?
-
Hi, I have the following C++ code, using MS-studio.Net (MFC). CDatabase aDatabase; TCHAR buffer[400]; SQLRETURN rc = SQLGetInfo(aDatabase.m_hdbc, SQL_DATABASE_NAME,(SQLPOINTER buffer, sizeof(buffer), &size); With this code at present, the value returned in buffer if "master" if the DSN is not pointing to any database. I think master is the default database. I actually want to know if the DSN is pointing to a correct(existing) database or not. I wanted to display a message if the DSN is not pointing to any database or if its pointing to a database that no more exists. How can I achieve this? Anybody any thoughts? Thanks, Joe
-
Hi, I have the following C++ code, using MS-studio.Net (MFC). CDatabase aDatabase; TCHAR buffer[400]; SQLRETURN rc = SQLGetInfo(aDatabase.m_hdbc, SQL_DATABASE_NAME,(SQLPOINTER buffer, sizeof(buffer), &size); With this code at present, the value returned in buffer if "master" if the DSN is not pointing to any database. I think master is the default database. I actually want to know if the DSN is pointing to a correct(existing) database or not. I wanted to display a message if the DSN is not pointing to any database or if its pointing to a database that no more exists. How can I achieve this? Anybody any thoughts? Thanks, Joe
Ask for the schema:
SELECT TABLE_CATALOG FROM INFORMATION_SCHEMA.TABLES GROUP BY TABLE_CATALOG
Look up INFORMATION_SCHEMA in BOL if you need to verify more than just the catalog (database) name.