首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >VB6 SQL脚本命令包含无法识别的短语/关键字

VB6 SQL脚本命令包含无法识别的短语/关键字
EN

Stack Overflow用户
提问于 2017-02-02 20:53:41
回答 1查看 193关注 0票数 0

当我将SQL从VB6代码复制到Foxpro中时,我正在将SQL insert语句写到Foxpro中,没有问题。当我使用相同的SQL并将其复制到测试程序时,它没有插入任何问题。当我在原始程序中执行SQL时,我得到“命令包含无法识别的短语/关键字”。

cnSO就是我在测试程序中使用的connection对象,与我在实时程序中使用的连接字符串相同。

代码语言:javascript
复制
insertSQL = "insert into soordeht (" & insertFields & ") values (" & Replace(insertData, Chr(34), "'") & ")"
Debug.Print insertSQL
'Debug.Print (insertFields)
'Debug.Print (insertData)
cnSO.Execute ("set null off")
cnSO.Execute (insertSQL)

这是输出的SQL

代码语言:javascript
复制
insert into soordeht (ordnum,number,orddate,time,ordtype,origin,name,address1,credline1,address2,city,state,zip,country,contact,tcode_1,tcode_2,tcode_3,agginvoice,division,discperc,taxzone,shipcode,shipname,shipadd1,shipadd2,shipcity,shipst,shipzip,shipctry,shipphone,shiparea,dist_ctr,store_no,dept_num,consacct,shipaymeth,billname,billadd1,billadd2,billcity,billst,billzip,billphone,custponum,cred1or2,shipvia,termcode,whnum,prtstatus,invoiceprt,orderprt,packprt,userid,slpcode,slpcomm,slpperc,comtype,compaid,comchgpcnt,comchgdays,comchgwarn,deldate,fax,areafax,source,trans_num,cross_dock,shipref,numlabels,paytype,shipstatus,status,fre_tax,trackingno,comment) values ("20026513","02658",{^2017-01-20},"11:37PM","S","L","KIDS ROOM, INC","GARY AND ED GOTLIEB","GARY AND ED GOTLIEB","5801 WESTHEIMER","HOUSTON","TX","77005","","GARY AND ED","00","00","00",.F.,"00",0,"","70290","C&S WHOLESALE GROCERS","OLD FERRY ROAD","","BRATTLEBORO","VT","05301","","","","","","","","","","","","","","","","722480","N ","","CC","DEF","Y",.T.,.T.,.T.,"SUP","HOU",5,100,"",0,0,0,0,{^2017-02-21},"","","ED^","35417","","",0,0,"Y","S","N","","")
EN

回答 1

Stack Overflow用户

发布于 2017-06-23 01:46:23

在VFP语言中,用来填充表中给定字段的replace函数。我想你应该用'代替",如果是这样的话,你应该使用STRTRAN(string to transform, string to seek, string to replace)

代码语言:javascript
复制
insertSQL = "insert into soordeht (" & insertFields & ") values (" & STRTRAN(insertData, '"', "'") & ")"

请注意,第二个参数是包含在' '中的",第三个参数是包含在" "中的',这是因为您需要以不同的方式包含' enclosure‘,或者像您第一次那样调用CHR(34)函数。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42002801

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档