SQLTables fails when database name include underscore. 
Author Message
 SQLTables fails when database name include underscore.

Hi all

I'm writing a VC++ MFC application that access an MS SQLServer using ODBC
API functions.

I'm using the function  ::SQLTables  to retrieve a list of all tables in a
given database.
The given database is NOT the default database for the current connection.

This is the relevant syntax
////////////////////////////////////////////////////////////////////////////

TCHAR        szCatalogName[] = {"MyDatabase"};
ret = ::SQLTables(m_hStmt, (UCHAR FAR*)szCatalogName, SQL_NTS,
                                        NULL, 0, NULL, 0, NULL, 0);
.....

ret = ::SQLBindCol(m_hStmt, 1, SQL_C_CHAR, szCatalog, 512, &cbCatalog);
ret = ::SQLBindCol(m_hStmt, 2, SQL_C_CHAR, szSchema, 512, &cbSchema);
ret = ::SQLBindCol(m_hStmt, 3, SQL_C_CHAR, szName, 512, &cbName);
ret = ::SQLBindCol(m_hStmt, 4, SQL_C_CHAR, szType, 512, &cbType);
ret = ::SQLBindCol(m_hStmt, 5, SQL_C_CHAR, szRemarks, 512, &cbRemarks);
.......

ret = ::SQLFetch(m_hStmt);

if(Ret == SQL_NO_DATA_FOUND)
   AfxMessageBox("No Tables Found", MB_OK|MB_ICONINFORMATION);
.....
////////////////////////////////////////////////////////////////////////////

If the name of the database is as shown above, everything is OK.
But if the name contains an underscore I get SQL_NO_DATA_FOUND.

////////////////////////////////////////////////////////////////////////////

TCHAR        szCatalogName[] = {"My_Database"};
ret = ::SQLTables(m_hStmt, (UCHAR FAR*)szCatalogName, SQL_NTS,
                                        NULL, 0, NULL, 0, NULL, 0);
.....
////////////////////////////////////////////////////////////////////////////

I tested this behavior several times with different ways of
code implementation and different database names.

Whenever there is an underscore in the database name I get
SQL_NO_DATA_FOUND.

If the database that its name contains the underscore is the connection's
default database there are no problems.

does any one know how to solve this??????

Any Help Will Be Helpful

aRIEL



Mon, 18 Aug 2003 20:16:53 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. CLS, naming, underscore, and readonly properties

2. Prefixing names with an underscore

3. When is it ok to prefix names with an underscore

4. Leading underscore in function name

5. Lib file for dll contains underscore in front of names

6. ::SQLTables; Bug or strange behavior

7. SQL Server SQLTables MDAC 2.1

8. ATLSOAP: sproxy generated SOAP proxy class fails when server responses include unknown elements

9. INCLUDING FAILS

10. CRichEditCtrl Copy function fails to include the standard text formats CF_RTF and CF_RETEXTOBJ

11. including "WinNetWk.h" fails

12. func prototypes: include parameter name?

 

 
Powered by phpBB® Forum Software