Source language: Translate to:

dbfQuery Question

Questions about NeoBook PlugIns

Moderator: Neosoft Support

dbfQuery Question

Postby Maviz » Fri May 26, 2006 9:34 pm

Somebody please tell me why in NeoBookDB version 2.3d the syntax
dbfQuery "[PubDir]\SAMPLE.dbf" "YEAR=1978" works but syntax
dbfQuery "[PubDir]SAMPLE.dbf" "YEAR>1978" wont works.
The error message is: No matching records found.
While there are years greater than 1978

Thanks
Maviz
 
Posts: 3
Joined: Fri May 26, 2006 9:26 pm

Postby Cipolla » Sat May 27, 2006 2:58 am

Maviz,

did you declare the field for the years as numeric or as a string? If it is a string the operator ">" will not work.
Also i noticed, that you have a backslash in your first query, but not in the other one. I can´t tehst it now, but maybe check this out.
Greetings from Germany
Klaus
User avatar
Cipolla
 
Posts: 166
Joined: Fri Apr 01, 2005 1:45 am
Location: Germany

Postby Maviz » Sat May 27, 2006 5:59 am

Dear Cipolla:

Thank you very much for your comments

Unfortunately I was declare all my fields in string format according to the misleading explanation in NeobookDB help as stated in below:

“Since NeoBook doesn't really distinguish between text and numbers the way traditional programming environments do, you can get by with defining all of you fields as strings if you like. The only exception would be if you plan on opening your database file in another program.”

In fact beside the problem I was encountered in dbfQuery syntax, all numbers in string format do the same behaviors as integer.

Regards

PS

The existence of backslash was a typo. Sorry about that.
Maviz
 
Posts: 3
Joined: Fri May 26, 2006 9:26 pm

Postby smartmedia » Sat Sep 16, 2006 1:08 pm

Hi...

Dave,
When you make a query var [dbfQueryResult] returns the total records found. If there are not any records found returns 0.
Now if i use the command dbfShowAll the [dbfQueryResult] also returns 0... This is problem... Is possible to change it into -1 or to False or Showall or what ever, just to be different...


Thanks
User avatar
smartmedia
 
Posts: 889
Joined: Fri Apr 01, 2005 6:50 am
Location: Hellas

Postby Gaev » Sat Sep 16, 2006 1:42 pm

smartmedia:

According to the Help file ...
You can use the global variable [dbfQueryResult] to determine if the query was successful. [dbfQueryResult] will contain the number of records found during the most recent query.
... when you do a dbfShowAll, it does NOT count as the most recent query.
dbfQueryCount

Purpose: This action performs a physical count of the number of active records in the database. If a query is active, the result reflects the number of found records. When no query is active, the result reflects the total number of records in the database.
... so you can use dbfQueryCount immediately after a dbfShowAll.
User avatar
Gaev
 
Posts: 3716
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby smartmedia » Sat Sep 16, 2006 2:31 pm

Hi...

Gaev,

May be i wasn't very clear...
I have a dbf table, an combobox and two buttons. I choose from the combobox a query and push the button to search. Now if no one record found i want to hide the table and show a text say "They are no records" So far everything is ok. (I control that with the [dbfQueryResult] and an IF command). Now the other button show all the records and the table, if my [dbfQueryResult] is 0 i can't show the table...

I hope you understand...
User avatar
smartmedia
 
Posts: 889
Joined: Fri Apr 01, 2005 6:50 am
Location: Hellas

Postby Gaev » Sat Sep 16, 2006 4:18 pm

smartmedia:

Say your dbf file name (alias) is "smDBF".

Say your ComboBox has ...
- Variable contains "Item number"
- Variable to store selected item is [QueryNumber]

When user makes a selection in the ComboBox its "Selection Changed" section looks like ...
Code: Select all
SetVar "[thisQuery]" "QueryArray[QueryNumber]
... so if [QueryArray1], [QueryArray2] etc. have the syntax for the various supported queries, [thisQuery] will contain it for the selection made by user.

Click section for Button2 ...
Code: Select all
dbfQuery "smDBF" "[thisQuery]"
If "[dbfQueryResult]" ">" "0"
   ShowObject "smDBFTable" "" "0"
   SetVar "[RecordsInTable]" "[dbfQueryResult]"
Else
   HideObject "smDBFTable" "" "0"
   dbfQueryCount "smDBF" "[RecordsInTable]"
EndIf


Click section for Button1 ...
Code: Select all
ShowObject "smDBFTable" "" "0"
dbfShowAll "smDBF"
dbfQueryCount "smDBF" "[RecordsInTable]"


So, [RecordsInTable] will always show number of records in the table ... either after the dbfQuery or dbfShowTable.

If I have misunderstood your objective, perhaps you can post your code here.
User avatar
Gaev
 
Posts: 3716
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby smartmedia » Sat Sep 16, 2006 11:42 pm

Gaev,

I have upload an example so you can understand better...

You can download it from here.

http://rapidshare.de/files/33406287/test.rar
User avatar
smartmedia
 
Posts: 889
Joined: Fri Apr 01, 2005 6:50 am
Location: Hellas

Oops ... didn't check my last suggestion enough ...

Postby Gaev » Sun Sep 17, 2006 12:35 pm

smartmedia:

... sent you another PM
User avatar
Gaev
 
Posts: 3716
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby smartmedia » Sun Sep 17, 2006 12:44 pm

Hi...

Thanks Gaev i receive your PM... Worked as you said.. Perfect... Thanks again...
User avatar
smartmedia
 
Posts: 889
Joined: Fri Apr 01, 2005 6:50 am
Location: Hellas


Return to PlugIn Discussions

Who is online

Users browsing this forum: No registered users and 2 guests