ADODC控件数据库开发!欢迎讨论!
给位朋友,我是初学VB的新手
我用ADODC控件编写数据库MIS系统,添加记录进去很简单:
既:Me.Adodc1.Recordset.addnew
  Me.Adodc1.Recordset.Fields(0).Value = Trim(Me.Text1)
  Me.Adodc1.Recordset.Fields(1).Value = Trim(Me.Text2)
  Me.Adodc1.Recordset.Fields(2).Value = Trim(Me.Text3)
  Me.Adodc1.Recordset.Update
  MsgBox ("添加成功")
但是,我却不知道怎么样修改记录,我是下面这样,记录无法保存:
 str = "update userinfo set name ='" & Trim(Me.Text4.Text) & "'where xh ='" & Trim(Me.Text1.Text) & "'"
  Me.Adodc1.RecordSource = str
请问我该如何才能ADODC控件来修改记录,谢谢了
我在线等待

解决方案 »

  1.   

    'Me.Adodc1.Recordset.addnew  '不要这句就是修改当前记录了.
      Me.Adodc1.Recordset.Fields(0).Value = Trim(Me.Text1)
      Me.Adodc1.Recordset.Fields(1).Value = Trim(Me.Text2)
      Me.Adodc1.Recordset.Fields(2).Value = Trim(Me.Text3)
      Me.Adodc1.Recordset.Update
      MsgBox ("添加成功")
      

  2.   

    要修改某条记录,只要移动到此记录,然后直接给要修改的字段赋予新值,
    再用update方法就行了.
      

  3.   

    Me.Adodc1.Recordset.Fields(0).Value = Trim(Me.Text1)
    Me.Adodc1.Recordset.Fields(1).Value = Trim(Me.Text2)
    Me.Adodc1.Recordset.Fields(2).Value = Trim(Me.Text3)
    Me.Adodc1.Recordset.Update
    MsgBox ("修改成功")
      

  4.   

    修改数据只要将添加的addnew去掉就行了.