Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP data to SQL server

Status
Not open for further replies.

FranklinYeung

Programmer
Apr 20, 2001
31
HK
Hi all,

i have encountered one problem when passing parameter to MS SQL server. But different version SQL server gives me differnent result. Here is the code that the program excuted:

oSQL = sqlconnect("MY_DB", {user_name}, {user_pwd})
lcDifference = 3
lcExec = "select dateadd(dd, ?lnDifference, getdate())"
oSQL_ans = sqlexec(oSQL, lcExec, 'xTemp')

Here is the summary of the difference
from 6.5 version :
value of oSQL_ans > 1 and correct result store in temp cursor xTEMP

from 7.0 & 2000 server:
value of oSQL_ans alway < 1, thus no data return


However, if the following codes are exectuted instead of assiging a parameter in the 'lcExec' string, no problem found and correct data returned in both 6.5, 7.0 & 2000

oSQL = sqlconnect(&quot;MY_DB&quot;, {user_name}, {user_pwd})
lcExec = &quot;select dateadd(dd, 5, getdate())&quot;
oSQL_ans = sqlexec(oSQL, lcExec, 'xTemp')


Any idea about this. Is that the up-to-date SQL server not accepting parameters by visual foxpro using the &quot;?&quot; before the variable(s)?



Franklin Yeung
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top