ID Row Just Added

  • Thread starter Thread starter Jack
  • Start date Start date
J

Jack

Hello,

I have a table like

ID - Int - Primary Key - AutoNumber
Test_Tile - NVARCHAR

I am Using the following code to add a row.

Dim con As New SqlConnection(SQLConnectString)
Dim cmd As New SqlCommand("INSERT INTO Test(Test_Title)
VALUES(@sTest_Title)", con)
Dim pTest_Title As New SqlParameter("@sTest_Title", SqlDbType.varchar, 50,
ParameterDirection.Input, False, 0, 0, Nothing,
DataRowVersion.Current,"Test")
cmd.Parameters.Add(pTest_Title)
con.Open()
cmd.ExecuteNonQuery()
con.Close()

I would like to be able to get the ID of the newly created row.

Any help would be great!!

Thanks,

Jack
 
Back
Top