We value your feedback.
Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!
Dim cn As New SqlConnection Dim cmd As New SqlCommand cn = GetConnected() cmd.Connection = cn cmd.CommandText = sSQL cmd.Parameters.Add(New SqlParameter("@FromDate", SqlDbType.DateTime)) ' etc - more parameters added ' This works - the record is added with a visible uniqueidentifier cmd.ExecuteNonQuery() ' This is where I'm trying to grab the Primary Key, but it returns a null.... cmd.Parameters.Clear() cmd.CommandText = "SELECT @@IDENTITY" Dim newID As String = "" & cmd.ExecuteScalar() ' ... so all of the record added here have a blank SessionID sSQL = "INSERT INTO tblScheduleStuff (Scheduler_SessionID, GenericStuff) SELECT '" & newID & "', Stuff FROM tblTEMPStuff" cmd.CommandText = sSQL cmd.ExecuteNonQuery()
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
|getting error Subquery returned more than 1 value||6||24|
|How to lock a table waiting for a store procedure is executed||21||40|
|Need help with another query||10||39|
|Problem Backingh Up Transaction Log on Old SQL000 Database||3||25|