Logo 
Search:

Asp.net Answers

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds
  Question Asked By: Dale Matthews   on Jul 26 In Asp.net Category.

  
Question Answered By: Kristin Johnston   on Jul 26

I tried what you suggested, the .ExecuteNonQuery and then
the .ExecuteScalar("SELECT @@Identity FROM myTable") and it worked.
I'm with you in thinking that it sure seems clunky. Any better ways
are welcomed to replace this:


Dim myConnection As New OleDbConnection
(fConnectionString)

Dim strSQL As String = "INSERT INTO tblDances
(AdminID) VALUES(1)"
Dim myCommand As New OleDbCommand(strSQL,
myConnection)
myCommand.Connection.Open()

myCommand.ExecuteNonQuery()

strSQL = ""
strSQL = "SELECT @@Identity FROM tblDances"

Dim cmd As New OleDbCommand(strSQL, myConnection)

Dim intDanceID As Integer

intDanceID = CType(cmd.ExecuteScalar(), Integer)

lblDanceID.Text = intDanceID

myConnection.Close()

Share: 

 

This Question has 7 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on How do I load MS Access @@Identity into ExecuteScalar? Or get search suggestion and latest updates.


Tagged: