text 已绑定adodc1
我的代码如下
Private Sub Cmdadd_Click()'Adodc1.Recordset.AddNew
'Adodc1.Recordset.Fields("wno") = Txtwno.Text
'Adodc1.Recordset.Fields("wname") = Txtwname.Text
'Adodc1.Recordset.Fields("storenum") = Txtstorenum.Text
''Adodc1.Recordset.Fields("unit") = Txtunit.Text
'Adodc1.Recordset.Update
End Sub
每次新增数据就会把指针指向的记录修改掉

解决方案 »

  1.   

    Adodc1.Refresh
    'Adodc1.Recordset.AddNew 
    'Adodc1.Recordset.Fields("wno") = Txtwno.Text 
    'Adodc1.Recordset.Fields("wname") = Txtwname.Text 
    'Adodc1.Recordset.Fields("storenum") = Txtstorenum.Text 
    ''Adodc1.Recordset.Fields("unit") = Txtunit.Text 
    'Adodc1.Recordset.Update 
    End Sub 
      

  2.   

    直接使用ADODB.Connection.Execute吧
      

  3.   

        因为你绑定了文本框,所以修改文件框内的数据再用addnew添加数据,等同于修改文本框内的数据后先update,再addnew,所以当前数据就被修改了。如果你想利用同一个文本框既显示又赋值,那就请你删除所有的绑定(即不要用绑定)。以下是个例子,文本框与ADODC没有绑定。Private Sub Command1_Click()'添加新记录
        Adodc1.Recordset.AddNew
        Adodc1.Recordset.Fields("a") = Text1.Text
        Adodc1.Recordset.Fields("b") = Text2.Text
        Adodc1.Recordset.Fields("c") = Text3.Text
        Adodc1.Recordset.Fields("d") = Text4.Text
        Adodc1.Recordset.Update
    End SubPrivate Sub Command2_Click()'逐条显示记录
        
        If Not Adodc1.Recordset.EOF Then
            Text1.Text = Adodc1.Recordset.Fields("a")
            Text2.Text = Adodc1.Recordset.Fields("b")
            Text3.Text = Adodc1.Recordset.Fields("c")
            Text4.Text = Adodc1.Recordset.Fields("d")
            Adodc1.Recordset.MoveNext
        End If
        
    End Sub