Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

When I try this:

 

[edit]Please use code tags when posting code, Joe.[/edit]

Private Function DataWrite() as Boolean
AddHandler Adapter1.RowUpdated, AddressOf HandleRowUpdated
Try
Global.Command1 = New OleDbCommand
Global.Command1.CommandText = "SELECT @@IDENTITY"
Global.Command1.Connection = Connection1
Global.Command1.Connection.Open()
Adapter1.Update(DataTable1)
Global.Command1.ExecuteNonQuery()
Global.Command1.Connection.Close()
Return True
Catch ex As Exception
lblError.Visible = True
lblError.Text &= "Database Save Error.<br>" & _
"Error: " & ex.Message
Global.Command1.Connection.Close()
Return False
End Try
End Function

Private Sub HandleRowUpdated(ByVal sender As Object, ByVal e As OleDbRowUpdatedEventArgs)
If e.Status = UpdateStatus.Continue _
AndAlso e.StatementType = StatementType.Insert Then
' Get the Identity column value
e.Row("ID") = _
Int32.Parse(Global.Command1.ExecuteScalar().ToString)
txtClientID.Text = e.Row("ID").ToString
e.Row.AcceptChanges()
End If
End Sub

 

The problem is that e.Row("ID") is not returning anything.

 

When I look at my Access database, there is only one entry, and it is number 87 (the rest have been removed to help us debug).

 

Could anyone tell me why I am getting this error and please explain how to fix it?

 

Thanks,

Joe

Edited by Derek Stone

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...