G
Guest
Hello,
I’m adding a record to a SQL database. One of the columns in the database
generates a uniquely identifying integer when a record is added. I would like
to retrieve this number when I add a new record to the table. By the way I do
not want to use stored procedures.
I’m using the following VB.NET code to add a record to a database how would
I change this so that at the same time I can retrieve the unique record id
generated by the database in the table?
Imports System.Data.SqlClient
Dim conDB As SqlConnection
Dim strInsert As String
Dim cmdInsert As SqlCommand
conDB = New SqlConnection("connection string")
strInsert="Insert Products (ProdName,ProdCat) Values ('Flat Chair',’Chair’)"
cmdInsert = New SqlCommand(strInsert, conDB)
conDB.Open()
cmdInsert.ExecuteNonQuery()
conDB.Close()
Thank you.
I’m adding a record to a SQL database. One of the columns in the database
generates a uniquely identifying integer when a record is added. I would like
to retrieve this number when I add a new record to the table. By the way I do
not want to use stored procedures.
I’m using the following VB.NET code to add a record to a database how would
I change this so that at the same time I can retrieve the unique record id
generated by the database in the table?
Imports System.Data.SqlClient
Dim conDB As SqlConnection
Dim strInsert As String
Dim cmdInsert As SqlCommand
conDB = New SqlConnection("connection string")
strInsert="Insert Products (ProdName,ProdCat) Values ('Flat Chair',’Chair’)"
cmdInsert = New SqlCommand(strInsert, conDB)
conDB.Open()
cmdInsert.ExecuteNonQuery()
conDB.Close()
Thank you.