我想通过与adodc绑定的text向数据库中添加数据,具体该怎么做?

解决方案 »

  1.   

    adodc.addnew
    adodc!字段名= text1.text
    adodc.Update
      

  2.   

    Private Sub Command1_Click()
    Adodc1.Recordset.AddNew
    Adodc1.Recordset("id") = Text1.Text
    Adodc1.Recordset("filename") = Text1.Text
    Adodc1.Recordset.Update
    Adodc1.Refresh
    End Sub
    你指定TEXT的时候,只要指定数据源,不要指定字段.要不会自动定位到最后一条记录,改动也直接对数据进行改动了.
    TEXT1.datasource=adodc1
    就可以了
      

  3.   

    如果想修改记录呢?
    Private Sub Command1_Click()
    Adodc1.Recordset.Edit
    Adodc1.Recordset("id") = Text1.Text
    Adodc1.Recordset("filename") = Text1.Text
    Adodc1.Recordset.Update
    Adodc1.Refresh
    End Sub是上面那样么,会出错阿
      

  4.   

    找到相应记录
    Adodc1.Recordset("id") = Text1.Text
    Adodc1.Recordset("filename") = Text1.Text Adodc1.Recordset.Update不要加adodc1.recordset.edit