Source language: Translate to:

Database Query Help

Questions about NeoBook PlugIns

Moderator: Neosoft Support

Database Query Help

Postby stevec » Thu Aug 09, 2007 6:56 am

I have another database question.

Here is my code for the query's
It comes up with a query syntax error.
I'm using a calendar to select the date, variable [cDate]
The database then goes and gets all the records for that date.
Then I'd like it to run the following queries and return the results
in the variables defined, IE: [Count], [Count1], [Count2]

Currently, it's not selecting just the date indicated.

dbfQuery "F:\PUBLIC\Installs\PCMain.dbf" "Date=[cDate] and GoogleTBR=Google Removed"
dbfQueryCount "F:\PUBLIC\Installs\PCMain.dbf" "[Count]"
Delay "1000"
dbfQuery "F:\PUBLIC\Installs\PCMain.dbf" "Date=[cdate] and YahooTBR=Yahoo Removed"
dbfQueryCount "F:\PUBLIC\Installs\PCMain.dbf" "[Count1]"
Delay "1000"
dbfQuery "F:\PUBLIC\Installs\PCMain.dbf" "Date=[cDate] andSpyBot=Spybot Removed"
dbfQueryCount "F:\PUBLIC\Installs\PCMain.dbf" "[Count2]"


Thanks;
SteveC
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

Postby Gaev » Thu Aug 09, 2007 7:55 am

stevec:

From the Help file for NeoBookDB ... pertaining to dbfQuery comand ...
Code: Select all
If the search string contains any spaces, then it must be surrounded with quotes which, in NeoBook, are specified using the special code: [#34]. For example:

"City=[#34]St. Louis[#34]"

Your queries have phrases like Google Removed, Yahoo Removed etc. ... they should be enclised in the special code [#34] e.g. ...
Code: Select all
dbfQuery "F:\PUBLIC\Installs\PCMain.dbf" "Date=[cDate] and GoogleTBR=[#34]Google Removed[#34]"
User avatar
Gaev
 
Posts: 3734
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

I don't know how you do it

Postby stevec » Thu Aug 09, 2007 8:11 am

Gaev;
I don't know how you do it.
I tried the same [#34], mine didn't work, yours did.

Thanks again;
:P :P :P :P
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

Postby Wrangler » Thu Aug 09, 2007 8:25 am

Steve:

Maybe this is why it didn't work for you.

dbfQuery "F:\PUBLIC\Installs\PCMain.dbf" "Date=[cDate] andSpyBot=Spybot Removed"

should be a space between "and" & "spybot"

dbfQuery "F:\PUBLIC\Installs\PCMain.dbf" "Date=[cDate] and SpyBot=Spybot Removed"

so this code should work:

dbfQuery "F:\PUBLIC\Installs\PCMain.dbf" "Date=[cDate] and SpyBot=[#34]Spybot Removed[#34]"

It probably would have worked for you when you tried it. Whenever I get these types of errors, first thing I do is run the program again, drop the debug box, run the code, and the debugger will show the line with the syntax error. Then you look for these simple mistakes.

This happens to me every now and again. I get in a hurry I guess.

If the code you posted just contains a typo, disregard this notice. :)
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1507
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Thanks

Postby stevec » Thu Aug 09, 2007 9:45 am

Thanks for the reply.

Just another small inquiry;

Is there a way to supress the "No Matching records found" dialog box.

For example, if I select the date, and then it queries the database, and finds no Windows 2000 systems, it pops up with the above dialog box and places the number of records into the count box?

Can you supress this and have it default to 0?

Thanks;
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

Postby Wrangler » Thu Aug 09, 2007 9:50 am

dbfShowErrors "False"

[dbfqueryresult] will show 0 if no matching records are found.
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1507
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Thanks;

Postby stevec » Thu Aug 09, 2007 10:05 am

Thanks;
Where would you place the [dbfqueryresult]

here is my code:
The message box is suppressed- THANKS :P :P :P

lgaMonthCalendar "" "1"
Delay "1000"
dbfQuery "F:\PUBLIC\Installs\PCMain.dbf" "Date=[cDate]"
dbfQueryCount "F:\PUBLIC\Installs\PCMain.dbf" "[2]"
dbfShowErrors "False"


dbfQuery "F:\PUBLIC\Installs\PCMain.dbf" "Date=[cDate] and OS=[#34]Windows XP[#34]"
dbfQueryCount "F:\PUBLIC\Installs\PCMain.dbf" "[Count3]"
dbfShowErrors "False"

dbfQuery "F:\PUBLIC\Installs\PCMain.dbf" "Date=[cDate] and OS=[#34]Windows 2000[#34]"
dbfQueryCount "F:\PUBLIC\Installs\PCMain.dbf" "[Count4]"
dbfShowErrors "False"


dbfQuery "F:\PUBLIC\Installs\PCMain.dbf" "Date=[cDate] and GoogleTBR=[#34]Google Removed[#34]"
dbfQueryCount "F:\PUBLIC\Installs\PCMain.dbf" "[Count]"
dbfShowErrors "False"

dbfQuery "F:\PUBLIC\Installs\PCMain.dbf" "Date=[cDate] and YahooTBR=[#34]Yahoo Removed[#34]"
dbfQueryCount "F:\PUBLIC\Installs\PCMain.dbf" "[Count1]"
dbfShowErrors "False"

dbfQuery "F:\PUBLIC\Installs\PCMain.dbf" "Date=[cDate] and Spybot=[#34]Spybot Removed[#34]"
dbfQueryCount "F:\PUBLIC\Installs\PCMain.dbf" "[Count2]"
dbfShowErrors "False"

dbfShowAll "F:\PUBLIC\Installs\PCMain.dbf"
dbfQuery "F:\PUBLIC\Installs\PCMain.dbf" "Date=[cDate]"
dbfQueryCount "F:\PUBLIC\Installs\PCMain.dbf" "[2]"
dbfShowErrors "False"
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

Postby Wrangler » Thu Aug 09, 2007 10:11 am

[dbfqueryresult] is a read only variable. You can place it in a text box, button label, or any place that will accept a variable. When you run a query, it will display the number of records found, or 0 if none found.

You may want to browse through the help file. There are a lot of little powerful features that are available, that aren't obvious until you read it.

Also, you only need to use dbfshowerrors once, usually in the startup actions right after you open the db. It will kill error box until you turn it to "true".

And, you don't need to use dbfshowall before each query. This is done automatically as you can't query within a query.

Just saves some coding. :)
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1507
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

got it

Postby stevec » Thu Aug 09, 2007 10:15 am

Here's the code that I used and it works;

If "[dbfqueryresult]" "=" "0"
SetVar "[Count4]" "0"
Else
EndIf

Thanks;
SteveC
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

Postby Wrangler » Thu Aug 09, 2007 10:19 am

If "[dbfqueryresult]" "=" "0"
SetVar "[Count4]" "0"
Else
EndIf


Since you are not providing a second condition to the IF statement, you don't need the Else.

If "[dbfqueryresult]" "=" "0"
SetVar "[Count4]" "0"
EndIf
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1507
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Thanks

Postby stevec » Thu Aug 09, 2007 10:19 am

I went through the help file, but your right.
There are alot of things it doesn't tell you.

many many thanks again

SteveC
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

Thanks

Postby stevec » Thu Aug 09, 2007 10:59 am

I went through the help file, but your right.
There are alot of things it doesn't tell you.

many many thanks again

SteveC
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho


Return to PlugIn Discussions

Who is online

Users browsing this forum: No registered users and 2 guests