Source language: Translate to:

Problem with dbpQuery

Questions about our Advanced Database plug-in

Moderator: Neosoft Support

Problem with dbpQuery

Postby George Keer » Mon Sep 24, 2007 11:50 am

I can't get the following query to work with dbpro (trial) and a simple Access database. The code is basically copied from the adress book example of dbpro. I have three fields for constructing the query: two combo boxes and a text entry field. Whenever anything is selected in the first combo box ([sLanguage]) the query results in an "unknown error". With the first entry left blank, all queries on the two other objects work as expected. Querying the second box first in the script ([sCategory]) produces the same error, querying the third field first also.

SetVar "[Filter]" ""

If "[sLanguage]" ">" ""
SetVar "[Filter]" "language LIKE [#34]%[sLanguage]%[#34]"
EndIf

If "[sCategory]" ">" ""
If "[Filter]" ">" ""
SetVar "[Filter]" "[Filter] AND "
EndIf
SetVar "[Filter]" "[Filter]category LIKE [#34]%[sCategory]%[#34]"
EndIf

If "[query]" ">" ""
If "[Filter]" ">" ""
SetVar "[Filter]" "[Filter] AND "
EndIf
SetVar "[Filter]" "[Filter]content LIKE [#34]%[query]%[#34]"
EndIf

If "[Filter]" ">" ""
dbpQuery "dgdocs" "documents" "[Filter]"


Since I could not get this to work I tried it with NeobookDB and a .dbf file instead:

SetVar "[Filter]" ""

If "[sLanguage]" ">" ""
SetVar "[Filter]" "language=[sLanguage]"
EndIf

If "[sCategory]" ">" ""
If "[Filter]" ">" ""
SetVar "[Filter]" "[Filter] AND "
EndIf
SetVar "[Filter]" "[Filter]category=[sCategory]"
EndIf

If "[query]" ">" ""
If "[Filter]" ">" ""
SetVar "[Filter]" "[Filter] AND "
EndIf
SetVar "[Filter]" "[Filter]content=[query]"
EndIf

If "[Filter]" ">" ""
dbfQuery "[PubDir]dat\dgdocs.dbf" "[Filter]"

dbfQueryCount "[PubDir]dat\dgdocs.dbf" "[Count]"

This works perfectly.

Does anyone have any idea why the first attempt does not work or how to determine what is causing the "unknown error"?
George Keer
 
Posts: 2
Joined: Sat Sep 22, 2007 12:32 pm

Postby Gaev » Mon Sep 24, 2007 12:10 pm

George Keer:

I am assuming that your Database Table contains a field (column) called Language.

LANGUAGE is a Reserved SQL word ... SQL interpreters will think/act on it like its intended (reserved) use ... so you can't use it as a field (column) name.

Here http://developer.mimer.com/validator/sq ... -words.tml is a (unofficial) web page listing all RESERVED words.

Try and change the field name to something else ... like docLanguage ... or Lang etc.
User avatar
Gaev
 
Posts: 3716
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby George Keer » Tue Sep 25, 2007 7:09 am

Gaev,

thank you very much for reply: very much appreciated and right on target!

Do you think it would be possible to change the error message from "unknown" to something like "SQL query error"?

Best Regards

George
George Keer
 
Posts: 2
Joined: Sat Sep 22, 2007 12:32 pm

Postby Gaev » Tue Sep 25, 2007 7:21 am

George Keer:
Do you think it would be possible to change the error message from "unknown" to something like "SQL query error"?

a) I will let the author of NeoBookDBPro (Dave) provide the official answer ... I am just another NeoBook developer

b) I believe, in another post Dave mentioned that error messages ... which originate from within the database programs controlling the databases ... are passed on to you "as is" ... without modification ... as each of the programs (from MicroSoft, IBM, Oracle, MySQL etc. etc.) might respond differently to the same syntax error, it would be difficult to trap/modify them.
User avatar
Gaev
 
Posts: 3716
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Neosoft Support » Tue Sep 25, 2007 9:51 am

Do you think it would be possible to change the error message from "unknown" to something like "SQL query error"?


Gaev is exactly right. The error messages originate with the database engine and can be different depending on what type of database you're using. NeoBook simply passes these messages on to you as is.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA


Return to NeoBookDBPro

Who is online

Users browsing this forum: No registered users and 1 guest