Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim myconnection As SqlConnection Dim mycommand As SqlCommand Dim myreader As SqlDataReader Dim sql As String Dim connStr As String Dim lcField1 As String Dim lcField2 As String Dim lcField3 As String lcField1 = Me.TextBox1.Text lcField2 = Me.TextBox2.Text lcField3 = Me.TextBox3.Text Dim lnConfirmationNumber As Integer sql = "insert into psr (facilityName,description,ProblemDef) values (" & lcField1 & "," & lcField2 & "," & lcField3 & ")" connStr = "Server=localhost;uid=sa;pwd=x12cqi;database=ctoreversions" myconnection = New SqlConnection(connStr) myconnection.Open() mycommand = New SqlCommand(sql, myconnection) Try mycommand.ExecuteNonQuery() ' Get the confirmation Number sql = "select @@identity as newID" ' Need some code here to run the query and return store the value to the variable ' Close Connection myconnection.Close() ' Show and display the confirmation page Response.Redirect("confirm.aspx") Catch ex As Exception Me.TextBox3.Text = ex.ToString & "Command = " & sql.ToString End Try End Sub