Partial Class and Retrieving Primary Key on Insert
This is very strange to me. The code below will work perfectly fine in a Windows application but fails in an ASP.NET 2.0 application.
Anybody else run into this and if so, any resolution?
This is key because it is an easy way to retrieve the latest identity value from a newly inserted record.
A little history. In both Windows and ASP I am accessing sql2005 using TableAdapters. I used a Partial class so that I don't have to risk losing my code in the autogenerated code behind files for the tableadapter.
Code:
'--My Partial Class
Imports Microsoft.VisualBasic
Namespace zzzTableAdapters
Partial Public Class zzzTableAdapter
Public AutoID As Integer
Private Sub _adapter_RowUpdated(ByVal sender As Object, ByVal e As System.Data.SqlClient.SqlRowUpdatedEventArgs) Handles _adapter.RowUpdated
AutoID = e.Row.ItemArray(0).ToString '--Here the ID field is 0.
End Sub
End Class
End Namespace
Re: Partial Class and Retrieving Primary Key on Insert
An error without an error message?
Re: Partial Class and Retrieving Primary Key on Insert
no duh! In asp.net the Id field is not incremented but in vb.net it is!