find what newID() was created in vb.net and sql server 2005
Posted on 2007-08-02
I have the following code in vb.net 2005: -
sql = "insert into dbo.Products values (newid(),'" & _
txtProductName.Text & "', '" & _
txtStockCode.Text & "', '" & _
txtPrice.Text & "', '" & _
cmbStockLocation.SelectedValue.ToString & "', '" & _
cmbSupplier.SelectedValue.ToString & "')"
Dim command As New SqlClient.SqlCommand(sql, oConn)
In the first column it creates a newid via the newID() command. That new Id I need to use again in anothe sql statement in the same procedure. What I am trying to find out is how do I find what ID was created please so I can place it into another sql command after this insert.