插入错误:列名或提供的值数与表定义不匹配

时间:2011-06-22 09:59:37

标签: sql vbscript ado

Public Sub SaveRec()
'On Error Resume Next
Dim Chk As Integer
Dim chkD As Integer


If txtname.Text = "" Then
    Msg "Must provide News Agency Name....", vbCritical
    txtname.SetFocus
    Exit Sub
ElseIf Cboroute.Text = "" Then
     Msg "Must Provide Route ID......", vbCritical
    Cboroute.SetFocus
    Exit Sub
ElseIf cbostation.Text = "" Then
    Msg " Must Provide Station Code.... ", vbCritical
    cbostation.SetFocus
    Exit Sub
End If

SQL = Msg("Save Record! Is the information is correct", vbYesNo)
If SQL = vbNo Then
  Exit Sub
End If
If chkdirect.Value = vbChecked Then
   Chk = 1
Else
   Chk = 0
End If

If chkActive.Value = vbChecked Then
   chkD = 1
Else
   chkD = 0
End If

If CheckAdd = True Then
    SQL = ""
    SQL = "insert into SubAgency values('" & TXTCODE.Text & "','" & CboAgname.Columns(0).Value & "','" & txtname.Text & "','" & txtadd.Text & "','" & Cboroute.Columns(0).Value & "','" & cbostation.Columns(0).Value & "','" & txtlbl.Text & "','" & txtcomm.Text & "','" & txtbonus.Text & "','" & txtopbal.Text & "','" & CompId & "')"
    Conn.Execute SQL

ElseIf CheckModify = True Then
    SQL = ""

    SQL = "update NewsAgent set NA_NAME='" & CboAgname.Columns(0).Value & "'"
    SQL = SQL & " ,AG_NAME  ='" & txtname.Text & "'"
    SQL = SQL & " ,AG_ADDRESS ='" & txtadd.Text & "'"
    SQL = SQL & " ,AG_ROUTE  ='" & Cboroute.Columns(0).Value & "'"
    SQL = SQL & " ,AG_STATION ='" & cbostation.Columns(0).Value & "'"
    SQL = SQL & " ,AG_LABLE ='" & txtlbl.Text & "'"
    SQL = SQL & " ,AG_COMM='" & txtcomm.Text & "'"
    SQL = SQL & " ,AG_BONOUS='" & txtbonus.Text & "'"
    SQL = SQL & " ,Ag_OPbal='" & txtopbal.Text & "'"
    SQL = SQL & " ,AG_DIRECTBILL ='" & Chk & "'"
    'SQL = SQL & " ,IsActive ='" & chkD & "'"
    'SQL = SQL & " where AG_ID='" & TXTCODE.Text & "'"
    SQL = SQL & " and comp_id='" & CompId & "'"
    Conn.Execute SQL
End If

Globalrs.Requery
ShowData
Frame1.Enabled = False
Call SetToolbarNavigate(Me)
End Sub

0 个答案:

没有答案