以下是引用liuxingang28在2014-6-1 16:44:40的发言:
用 ExecScript() 执行 SQL 语句?我还是第一次碰到。楼主是不是把 SQLEXEC()函数与 EXECSCRIPT()函数混淆了?
如果在 SQL Server 上运行没有问题,则采用如下语句肯定也是没有问题的:
cSql = "SELECT cast(thick AS char(10)) as 厚度 FROM tb_中板仓库_b WHERE (jlsjh_tb_生产跟踪表 IN (SELECT jlsjh FROM Tb_细木板跟踪表 WHERE (RTRIM(LTRIM(单据编号)) ='xmgzb'+CAST(YEAR(GETDATE()) AS varchar(4))+RIGHT('0'+CAST(MONTH(GETDATE()) AS varchar(2)),2))))"
IF SQLEXEC(gnHandle,cSql,'curRet') > 0
BROWSE
ENDIF
我不是说过了:这没有问题,是select thick+venthick*2-1 AS char(10)) as 厚度,后提示出错了.SQLEXEC()函数与 EXECSCRIPT()函数当然不能混淆了,
lcsql="if tb_生产任务单.类别='中板'
othisform.sql.sqlexec("SELECT cast(thick AS char(10)) as 厚度 FROM tb_中板仓库_b WHERE (jlsjh_tb_生产跟踪表 IN (SELECT jlsjh FROM Tb_细木板跟踪表 WHERE (RTRIM(LTRIM(单据编号)) ='xmgzb'+CAST(YEAR(GETDATE()) AS varchar(4))+RIGHT('0'+CAST(MONTH(GETDATE()) AS varchar(2)),2))))","v_厚度"
else
othisform.sql.sqlexec("select thick+venthick*2-1 AS char(10)) as 厚度 FROM tb_中板仓库_b WHERE (jlsjh_tb_生产跟踪表 IN (SELECT jlsjh FROM Tb_细木板跟踪表 WHERE (RTRIM(LTRIM(单据编号)) ='xmgzb'+CAST(YEAR(GETDATE()) AS varchar(4))+RIGHT('0'+CAST(MONTH(GETDATE()) AS varchar(2)),2))))","v_厚度"
endif
...."
在VFP中执行
...
othisform=thisform
try
EXECSCRIPT(lcsql)
catch
...
endtry
....
提示出错了,问题已经一句句查清楚了,就是thick+venthick*2-1 AS char(10)) as 厚度,这句有问题?我说清楚了吗?我用cast(thick AS char(10)) as 厚度替换,正确,没有问题.
[
本帖最后由 lgp740401_72 于 2014-6-2 10:51 编辑 ]