Dim tmpstr As String
    Dim rs As New ADODB.Recordset
     tmpstr = "insert into cc(id,customerid,customername,address,employeeqj,cityid,cityname) values(" & _
                lblID.Caption & "," & _
                TransSQLChar(txtCustomer.Text) & "," & _
                TransSQLChar(txtCustomerName.Text) & "," & _
                TransSQLChar(txtaddress1.Text) & "," & _
                TransSQLChar(txtid.Text) & "," & _
                TransSQLChar(txtcityid.Text) & "," & _
                TransSQLChar(txtcityname.Text) & ""
执行时老是说该语句有问题!

解决方案 »

  1.   

    检查一下你的字段是否是字符型,是就要用单引号分开,如:Dim tmpstr As String
        Dim rs As New ADODB.Recordset
         tmpstr = "insert into cc(id,customerid,customername,address,employeeqj,cityid,cityname) values(" & _
                    lblID.Caption & ",'" & _
                    TransSQLChar(txtCustomer.Text) & "','" & _
                    TransSQLChar(txtCustomerName.Text) & "','" & _
                    TransSQLChar(txtaddress1.Text) & "','" & _
                    TransSQLChar(txtid.Text) & "','" & _
                    TransSQLChar(txtcityid.Text) & "','" & _
                    TransSQLChar(txtcityname.Text) & "'"^_^
      

  2.   

    那他应该会“提示类型不匹配”啊
    可是只是说”insert into 语句语法错误“
    郁闷!
      

  3.   

    在第四行的最后面多加了  " &  ,又在最后一行结尾出少了一个括号,修改后的如下:
    Dim tmpstr As String
        Dim rs As New ADODB.Recordset
         tmpstr = "insert into cc(id,customerid,customername,address,employeeqj,cityid,cityname) values(_
                    lblID.Caption & "," & _
                    TransSQLChar(txtCustomer.Text) & "," & _
                    TransSQLChar(txtCustomerName.Text) & "," & _
                    TransSQLChar(txtaddress1.Text) & "," & _
                    TransSQLChar(txtid.Text) & "," & _
                    TransSQLChar(txtcityid.Text) & "," & _
                    TransSQLChar(txtcityname.Text) & "")
      

  4.   

    TransSQLChar 是什么函数?
    tmpstr = "insert into cc(id,customerid,customername,address,employeeqj...
    之后加一句
    Debug.Print tmpstr
    看看究竟是什么内容。