以下是插入生产数据报表的VB程序,其中fWrawre0,fWrawcu0,iFraw0等是用户归档中的变量,tempv(0),ifra(0)是定义的内部变量,Tree5105.sbatch是PLC变量以及标点符号用的引号请问" & HMIRuntime.Tags("Tree5105.rwtsp").Read & "和'" & HMIRuntime.Tags("Tree5105.srecipes").Read & "'引号有什么区别?非常感谢!
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''插入一条生产数据
oCom.CommandText="INSERT INTO UA#Process(ID,sNbatch,sNrecipes,fWpro,sContainer,sOperator,tTstartpro,tTstoppro,"
oCom.CommandText=oCom.CommandText & "fWrawre0,fWrawcu0,iFraw0,fWrawre1,fWrawcu1,iFraw1,fWrawre2,fWrawcu2,iFraw2,fWrawre3,fWrawcu3,iFraw3,fWrawre4,fWrawcu4,iFraw4,"
oCom.CommandText=oCom.CommandText & "fWrawre5,fWrawcu5,iFraw5,fWrawre6,fWrawcu6,iFraw6,fWrawre7,fWrawcu7,iFraw7,fWrawre8,fWrawcu8,iFraw8,fWrawre9,fWrawcu9,iFraw9,fWrawre10,fWrawcu10,iFraw10)"
oCom.CommandText=oCom.CommandText & "VALUES(" & tempid & ",'" & HMIRuntime.Tags("Tree5105.sbatch").Read & "','" & HMIRuntime.Tags("Tree5105.srecipes").Read & "'," & HMIRuntime.Tags("Tree5105.rwtsp").Read & ",'" & HMIRuntime.Tags("Tree5105.stank").Read & "','" & HMIRuntime.Tags("@CurrentUserName").Read & "',0,0,"
oCom.CommandText=oCom.CommandText & tempv(0) & ",0," & ifra(0) & "," & tempv(1) & ",0," & ifra(1) & "," & tempv(2) & ",0," & ifra(2) & "," & tempv(3) & ",0," & ifra(3) & "," & tempv(4) & ",0," & ifra(4) & ","
oCom.CommandText=oCom.CommandText & tempv(5) & ",0," & ifra(5) & "," & tempv(6) & ",0," & ifra(6) & "," & tempv(7) & ",0," & ifra(7) & "," & tempv(8) & ",0," & ifra(8) & "," & tempv(9) & ",0," & ifra(9) & tempv(10) & ",0," & ifra(10)&) "
Set oRs = oCom.Execute
最佳答案
单引号是SQL语句的字符串限定符,加了单引号就代表该内容是字符串格式!
注意你字符串拼接格式,字符串需要用双引号标识。
oCom.CommandText & "tempv(0)…"
提问者对于答案的评价:
谢谢!
原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc320552.html