Dim cn As New ADODB.Connection
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Properties("Jet OLEDB:Database Password") = "quality"
cn.Open strCN
cn.Execute "insert into quality_issue(record_date,record_time,rec_id,shift,pkg,pkg_code,mach_id,device,lot_no,qty,defect_date,defect_time,badge,confirm,accident,process,category,reason,pm_issue)values('" & dtpDate.Value & "','" & dtpTime.Hour & ":" & dtpTime.Minute & ":" & dtpTime.Second & "','" & txtRec_id.Text & "','" & cboShift.List(cboShift.ListIndex) & "','" & cboPKG.List(cboPKG.ListIndex) & "','" & cboCode.List(cboCode.ListIndex) & "','" & txtMach_id.Text & "','" & txtDevice.Text & "','" & txtLot.Text & "','" & txtDef_Qty.Text & "','" & txtDef_Date.Text & "','" & txtDef_Time.Text & "','" & txtBadge.Text & "','" & txtConfirm.Text & "','" & RConfirm & "','" & cboProcess.List(cboProcess.ListIndex) & "','" & cboCategory.List(cboCategory.ListIndex) & "','" & CStr(txtDisc.Text) & "','" & cboPM.List(cboPM.ListIndex) & "')"
cn.Close
当运行到将textbox控件txtDisc的text字符串输入给access数据库reason字段时,如果字符串中包含单引号',就会报错:“Syntax error(missing operator) in query expression”,请问如何解决
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Properties("Jet OLEDB:Database Password") = "quality"
cn.Open strCN
cn.Execute "insert into quality_issue(record_date,record_time,rec_id,shift,pkg,pkg_code,mach_id,device,lot_no,qty,defect_date,defect_time,badge,confirm,accident,process,category,reason,pm_issue)values('" & dtpDate.Value & "','" & dtpTime.Hour & ":" & dtpTime.Minute & ":" & dtpTime.Second & "','" & txtRec_id.Text & "','" & cboShift.List(cboShift.ListIndex) & "','" & cboPKG.List(cboPKG.ListIndex) & "','" & cboCode.List(cboCode.ListIndex) & "','" & txtMach_id.Text & "','" & txtDevice.Text & "','" & txtLot.Text & "','" & txtDef_Qty.Text & "','" & txtDef_Date.Text & "','" & txtDef_Time.Text & "','" & txtBadge.Text & "','" & txtConfirm.Text & "','" & RConfirm & "','" & cboProcess.List(cboProcess.ListIndex) & "','" & cboCategory.List(cboCategory.ListIndex) & "','" & CStr(txtDisc.Text) & "','" & cboPM.List(cboPM.ListIndex) & "')"
cn.Close
当运行到将textbox控件txtDisc的text字符串输入给access数据库reason字段时,如果字符串中包含单引号',就会报错:“Syntax error(missing operator) in query expression”,请问如何解决
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货