INSERT SQL with SELECT SCOPE_IDENTITY()
identity = Integer.Parse(SQLCmd.ExecuteScalar().ToString()) objConnection.Close() Dim txtAssessmentID As String ' Set Assessment ID txtAssessmentID = identity.ToString txtAssessmentID = Year(Today) & "-" & txtAssessmentID.PadLeft(5, "0"c) strSQL = "UPDATE tblAssessment SET assessmentID = @assessmentID WHERE ID = " & identity SQLCmd = New SqlCommand() 'The SQL Command objConnection.Open() 'Open the connection SQLCmd.Connection = objConnection 'Sets the Connection to use with the SQL Command SQLCmd.CommandText = strSQL 'Sets the SQL String SQLCmd.Parameters.AddWithValue("@assessmentID", txtAssessmentID) Try objCommand.ExecuteNonQuery() objConnection.Close() ' Load Personell Evaluations Catch ex As Exception lblAlert.Text = "Problem updaaating record" End Try
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)