Microsoft 开发人员网络 > 论坛主页 > Visual Basic IDE > How to edit the records in datagridview and update changes into ms access data base?
提出问题提出问题
 

已答复How to edit the records in datagridview and update changes into ms access data base?

  • 2009年10月26日 14:17Jack1984 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    When i tried with the code discussed in this forum i am able to add records but not modify any particular existing record. throwed an error "Syntax error (missing operator) in query expression '((Mailing ListID = ?) AND ((? = 1 AND FirstName IS NULL) OR (FirstName = ?)) AND ((? = 1 AND MiddleName IS NULL) OR (MiddleName = ?)) AND ((? = 1 AND LastName IS NULL) OR (LastName = ?)) AND ((? = 1 AND Suffix IS NULL) OR (Suffix = ?)) AND ((? = 1 AND Nic'.

    code snippet

    'to access db

    Dim

    con As New OleDb.OleDbConnection

    con.ConnectionString =

    "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = D:\Access Test\TestDataBase.mdb"

    con.Open()

    sql =

    "SELECT * FROM ProductivityDetails1"

    da =

    New OleDb.OleDbDataAdapter(sql, con)

     

    Dim builder As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(da)

    ds =

    New DataSet()

    da.Fill(ds,

    "Productivity Details")

    DataGridView1.DataSource = ds.Tables(

    "Productivity Details").DefaultView

    con.Close()

    con =

    Nothing



    'to save changes

    Me

    .Validate()

     

    Me.da.Update(Me.ds.Tables("Productivity Details"))

     

    Me.ds.AcceptChanges()

答案

全部回复