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: Volney Fischer   on Jul 26

Ok, here is my code for my "LinkAdd" click. It does add a record. I'm
just trying to get back the record's autonumber at the same time I
append a row  (simplified for the purpose of illustration).
Pushing "F1" when my cursor is inside of ".ExecuteScalar" gives me
help which says: "Executes the query, and returns the first column  of
the first row in the resultset returned by the query. Extra columns
or rows are ignored." So, maybe it only works on Select queries, but
it DOES return  the first row and first column:


Private Sub LinkSave_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles LinkSave.Click
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()
Dim intDanceID As Integer

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

lblDanceID.Text = intDanceID-----Nothing happens here

myConnection.Close()

End Sub

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: