Results 1 to 3 of 3

Thread: database not updating

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2002
    Posts
    2

    Angry database not updating

    hopefully someone can give me some insight with this code, it is updating the dataset but not the database.

    Thanks

    'daAdapter.Update(dtChanges.GetChanges(DataRowState.Modified)

    OleDbConnection1.Open()
    '*************************************************************************************
    Dim drnew As System.Data.DataRow = dsers.Tables("retire").Rows(0) ' defining the new row
    drnew = dsers.Tables("retire").NewRow ' creating a empty row

    drnew.Item("fst_name") = Trim(TextBox1.Text).ToString ' insering value into empty row
    drnew.Item("ssn") = Trim(TextBox2.Text).ToString
    dsers.Tables("retire").Rows.Add(drnew) ' Adding new row to dataset
    dsers.AcceptChanges() ' Accepting the changes
    'dsers.GetChanges()
    TextBox4.Text = dsers.Tables("retire").Rows.Count
    '**************************************************************************************
    '* defining commandbuilder
    Dim custCB As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(OleDbDataAdapter1)
    OleDbDataAdapter1 = custCB.DataAdapter
    '************************
    'update the records

    Dim oleDBupdateComm1 As New System.Data.OleDb.OleDbCommand()
    Dim nRowsAffected As Integer
    Try


    oleDBupdateComm1.CommandText = "UPDATE RETIRE SET FST_NAME = @fst_name"
    OleDbDataAdapter1.UpdateCommand = oleDBupdateComm1
    dsers.Tables("retire").GetChanges()
    OleDbDataAdapter1.UpdateCommand.Parameters.Add("@fst_name", OleDb.OleDbType.VarChar, 25, "fst_name")

    OleDbDataAdapter1.Update(dsers, "retire")
    nRowsAffected = OleDbDataAdapter1.Update(dsers, "retire")
    TextBox2.Text = nRowsAffected
    Catch myerror As Exception
    MessageBox.Show(myerror.Message)
    Finally
    End Try
    OleDbConnection1.Close()

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Try removing acceptchanges

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2002
    Posts
    2
    Thanks that did it , such a simple thing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width