语句如下:Str1 = "INSERT INTO CompareMain (Xm_Code, Xm_Lb, Our_Code, Lb_Code,is_comp) values( '" & TDBText4.Text & " ' , '0 ' , '" & TDBText11.Text & " ', '0 ',0)" TDBText4.Text和TDBText11.Text的取数据的格式不对,哪位大哥帮帮忙,对应写入的字段是文本格式。
调试欢乐多
还有TDBText4.Text和TDBText11.Text的值中不能出现单引号。
"values(?,?,?,?,?)"一个字段对应一个问号,然后用adocommand对象来做,把?的值一个个放进去就行了。
rs.open "CompareMain",db, adOpenKeyset, adLockOptimistic
rs.addnewrs!Xm_Code=TDBText4.Text
rs!Xm_Lb=0
rs!Our_Code=TDBText11.Text
rs!Lb_Code=0
rs!is_comp=0rs.update