Loaddatarow adds a row even when pk exists in the dataset

  • Thread starter Thread starter Robby.lafarge
  • Start date Start date
R

Robby.lafarge

Here is the code. I know I am doing something wrong, but for the life of me I can't see it. I keeps adding a new row to the table rather than updating the current row. This is being called from a web form. I am really stuck and I need some guidance.


Private Sub updateuser()
Dim username As String
Dim xmdr(5) As Object
On Error GoTo handler
xmdr(0) = recordid
xmdr(1) = Trim(Me.email.Text)
xmdr(2) = Trim(Me.loginid.Text)
If Me.passwrd.Text <> Nothing Then
xmdr(3) = FormsAuthentication.HashPasswordForStoringInConfigFile(Trim(Me.passwrd.Text), "sha1")
Else
Me.passwrd.Text = DataGrid1.SelectedItem.Cells(3).Text
xmdr(3) = FormsAuthentication.HashPasswordForStoringInConfigFile(Trim(Me.passwrd.Text), "sha1")
End If
xmdr(4) = Me.company.Text
If CheckBox1.Checked = True Then
xmdr(5) = "A"
Else
xmdr(5) = "S"
End If
Dim userrow As DataRow
DataSet11.User_table.BeginLoadData()
DataSet11.User_table.LoadDataRow(xmdr, False)
DataSet11.User_table.EndLoadData()
'DataSet11.User_table.AcceptChanges()
Me.OleDbDataAdapter1.Update(DataSet11)
Me.DataSet11.Clear()
Me.OleDbDataAdapter1.Fill(DataSet11)
DataGrid1.DataBind()
Exit Sub

handler:
Dim errorval As String
errorval = Err.Description
'MsgBox(errorval, MsgBoxStyle.Information, "Error")
Resume Next

End Sub
 
Try setting theMissingSchemaAction property of the DataAdapter to
MissingSchemaAction.AddWithKey before calling Fill.
 
Back
Top