ID Row Just Added

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top