FranklinYeung
Programmer
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("MY_DB", {user_name}, {user_pwd})
lcExec = "select dateadd(dd, 5, getdate())"
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 "?" before the variable(s)?
Franklin Yeung
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("MY_DB", {user_name}, {user_pwd})
lcExec = "select dateadd(dd, 5, getdate())"
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 "?" before the variable(s)?
Franklin Yeung