在访问中插入显示错误

时间:2017-11-02 06:24:37

标签: database vba ms-access

Call connectDB
    sql = ""
    sql = sql & "INSERT INTO cust([Client Name],[Mobile No],[Address],[City],[State],[Pincode],[Email],[Category],[Contact Name],"
   sql = sql & "[Enquiry],[ActiveFlag])" & vbCrLf


                       sql = sql & " VALUES (" & vbCrLf
                        sql = sql & "'" & txtClientName.Text & "'," & vbCrLf
                        sql = sql & "'" & txtMobile.Text & "'," & vbCrLf
                        sql = sql & "'" & txtAddress.Text & "'," & vbCrLf
                        sql = sql & "" & txtcity.Text & "," & vbCrLf
                        sql = sql & "'" & txtState.Text & "'," & vbCrLf
                        sql = sql & "'" & txtPIN.Text & "'," & vbCrLf
                        sql = sql & "'" & txtEmail.Text & "'," & vbCrLf
                        sql = sql & "'" & cmbCatagory.Value & "'," & vbCrLf
                        sql = sql & "'" & txtContactPerson.Text & "')" & vbCrLf
                        sql = sql & "'Y','Y');"


                        cn.Execute sql

它显示错误,就像一个更多的值没有给出..但我给出了所有的值,它也给出了

  

在SQL语句的末尾需要使用Semicolon(;)

1 个答案:

答案 0 :(得分:0)

Call connectDB
    sql = ""
    sql = sql & "INSERT INTO cust([Client Name],[Mobile No],[Address],[City],[State],[Pincode],[Email],[Category],[Contact Name],"
   sql = sql & "[Enquiry],[ActiveFlag])" & vbCrLf


                       sql = sql & " VALUES (" & vbCrLf
                        sql = sql & "'" & txtClientName.Text & "'," & vbCrLf
                        sql = sql & "'" & txtMobile.Text & "'," & vbCrLf
                        sql = sql & "'" & txtAddress.Text & "'," & vbCrLf
                        sql = sql & "" & txtcity.Text & "," & vbCrLf
                        sql = sql & "'" & txtState.Text & "'," & vbCrLf
                        sql = sql & "'" & txtPIN.Text & "'," & vbCrLf
                        sql = sql & "'" & txtEmail.Text & "'," & vbCrLf
                        sql = sql & "'" & cmbCatagory.Value & "'," & vbCrLf
                        sql = sql & "'" & txtContactPerson.Text & "'," & vbCrLf
                        sql = sql & "'Y','Y');"


                        cn.Execute sql