• Welcome to Theos PowerBasic Museum 2017.

ODBC Services

Started by David Marco, September 24, 2008, 06:40:39 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

David Marco

Hi All,

I'm trying to create a ODBC Services.

I'm using the BIBLIO.MDB for compatibility issues.

I addapted the EX_ODBC_06.bas sample program in order to get the tablenames.

After this, following the sample of EX_ODBC_08.bas program, in order to get the fieldnames, I do this:

r = SQLExecDirect (hStmt, "SELECT * FROM " & szTableName, %SQL_NTS)

All works fine, but BIBIO.mdb has a table named "Title Author" with a space between words.
Each time szTableName is "Title Author", I received a error message number 4294965991.
I Receive this message in spanish, the translate message wold be something like this:

SQLState: 42S02
Native Error: 4294965991
[Microsoft][Microsoft Access ODBC Driver] Microsoft Jet Motor can't find the Table 'Title'. Be sure that this exists and its name is well written.

If I change the line:
r = SQLExecDirect (hStmt, "SELECT TOP 20 * FROM Titles ORDER BY Title", %SQL_NTS)
for this one:
r = SQLExecDirect (hStmt, "SELECT TOP 20 * FROM Title Author", %SQL_NTS)

in EX_ODBC_08.bas program, I get the same result.

Does any know the way to do a replacement of the space character, in order to get the fieldnames ?

Thanks in advance,
David

José Roca

Use r = SQLExecDirect (hStmt, "SELECT TOP 20 * FROM [Title Author]", %SQL_NTS)

David Marco

#2
Thanks José,

Now works fine.

I will assume the same behavior with field names ( put them between brackets [] ). Isn't it ?

Saludos desde Buenos Aires, Argentina
David

José Roca