Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP datetime used as parameter for SPT to SQL Server Pro
Message
From
02/02/2001 11:03:55
 
 
To
01/02/2001 20:32:55
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00471561
Message ID:
00471784
Views:
24
>I have a stored procedure in SQL Server 7 that incluses a select statement along the lines of SELECT * FROM table WHERE date_add >= @bdate and date_add <= @edate. @bdate and @edate are datetime parmaters to this procedure.
>
>The following SPT works fine:
>
>ln_return=SQLEXEC(ln_handle, "myproc '01/01/2001','01/01/2001'")
>*Note yes I should give it better strings -- but for teting purposes these work
>*fine.
>*ln_return=1
>*And I do indeed get one sqlresult cursor
>
>*This following fails
>ln_bdate=datetime()
>ln_edate=datetime()
>ln_return=SQLEXEC(ln_handle, "myproc ?d1,?d2")
>*ln_return = -1 meaning an error
>* and of course I get no results cursors
>* Is this an ODBC problem? A UFU on my part? Help!
>*

You will need to convert the date values to character strings before sending them to SQL server:
ln_return=SQLEXEC(ln_handle, "myproc " + DTOC(ln_bdate) + "," + DTOC(ln_edate))
Dan LeClair
www.cyberwombat.com
SET RANT ON - The Wombat Blog

Life isn’t a morality contest and purity makes a poor shield. - J. Peter Mulhern
Disclaimer: The comments made here are only my OPINIONS on various aspects of VFP, SQL Server, VS.NET, systems development, or life in general, and my OPINIONS should not be construed to be the authoritative word on any subject. No warranties or degrees of veracity are expressed or implied. Void where prohibited. Side effects may included dizziness, spontaneous combustion, or unexplainable cravings for dark beer. Wash with like colors only, serve immediately for best flavor.
Previous
Reply
Map
View

Click here to load this message in the networking platform