Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Query an SQL Server Table Problem
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01158161
Message ID:
01158169
Views:
19
This message has been marked as the solution to the initial question of the thread.
>I am trying to query a sql server table using the following:
>
>sqlexec(lnconnection,"Select * from invoices where invoices.ccustnum Like ?p_custnumparameter and invoices.ddatetimefield Like ?p_datetimeparameter","v_myresult")
>
>if I enter a date it returns the proper results, if I enter % (wildcard) I get no results
>
>I need to get all records for a customer regardless of date not only records for a specific date
Change query to look like this:
TEXT TO lcSQL NOSHOW
     Select *
            from invoices
            where invoices.ccustnum Like ?p_custnumparameter and
                  (p_datetimeparameter IS NULL OR invoices.ddatetimefield = ?p_datetimeparameter)
ENDTEXT
sqlexec(lnconnection,lcSQL,"v_myresult")

*** If you want customer info about particular Date:
p_custnumparameter = XXXXXXX
p_datetimeparameter = '20060929'
sqlexec(lnconnection,lcSQL,"v_myresult")

*** If you want ALL customer info regardless of date:
p_custnumparameter = XXXXXXX
p_datetimeparameter = NULL
sqlexec(lnconnection,lcSQL,"v_myresult")
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform