Using myCommand.ExecuteScalar, I have set my connection, built my
command object to insert a row, and created a new ID because of the
Autonumber column in an Access table. I know this because I've looked
at the underlying table in question.
What I want is to return that Autonumber value and I don't know how
to use ExecuteScalar to do it. Documentation says ExecuteScalar
returns what I want (first row, first column) in an object format. So
I should be able to run an INSERT query, and return @@Identity.
For now I would like to just see the @@Identity/AutoNumber on my Web
Form. This doesn't work:
Dim intNewID As Integer
intNewID = CType(myCommand.ExecuteScalar,Integer)
Me.lblNewID = intNewID
What am I missing, and is this the best way?