刚才的代码贴错了
private Sub Command1_Click()
Adodc1.Recordset.AddNew
With Adodc1
    .Recordset("驾驶员代码") = Trim(Text1.Text)
    .Recordset("姓名") = "1"
    .Recordset("是否离职") = "1"    .Recordset.Update
    
End With
End Sub

解决方案 »

  1.   

    //多看看MSDN上的例子吧!为什么你用
       Dim cnn1 As ADODB.Connection
       Dim rstEmployees As ADODB.Recordset
       
       rstEmployees.AddNew
          rstEmployees!驾驶员代码= Trim(Text1.Text)
          rstEmployees!姓名 = "1"
          rstEmployees!是否离职 = "1"    
        rstEmployees.Update
      

  2.   

    你的程序有误!对于一个adodb的对象,只是指定了数据库名,并没有指定表名。你可以试试用以下的程序代替
    Private Sub Command1_Click()
        Dim Rst1 As New ADODB.Recordset
        Rst1.Open "select * from 你要打开的表名", 联接字符串, adOpenDynamic, adLockBatchOptimistic
        Rst1.AddNew
        With Rst1
            !驾驶员代码=Trim(Text1.Text)
            !姓名="1"
            !是否离职="1"        .Update
        End With
        Rst1.Close    
    End Sub
      

  3.   

    private Sub Command1_Click()
    Adodc1.Recordset.AddNew
    官方正式写法:
    With Adodc1
        .Recordset.fields("驾驶员代码").value = Trim(Text1.Text)
        .Recordset.fields("姓名").value = "1"
        .Recordset.fields("是否离职").value = "1"    .Recordset.Update
        
    End With
    End Sub
      

  4.   

    我知道了,你要添加的字段是不是有非NULL字段,如果是这样的话你最好是用recordset.open"insert into  table....",....不知道我猜中了没有