After Inserting records successfully, I need to Redirect to the Next Page.
Currently I have decalred a Boolean variable and initial value for that has set to false.
Then in side the try block i am going to change the value for that variable as true.
After checking this value in a IF block, I can redirect to the next page.
Is this way is good or can you suggest a new way to do that.
Is there any way to get the affected rows and based on that how can i redirect it.
Thanks
Expand|Select|Wrap|Line Numbers
- 'Connection String and Other rest of the Coding Goes here
- Private Sub btn_submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_submit.Click
- Dim goToStep As Boolean = False
- Dim StrtxtQua As String = txtQua.Text
- Dim StrtxtGMC As String = txtGMC.Text
- Dim StrtxtSpcInterest As String = txtSpcInterest.Text
- Dim StrtxtNHS_post As String = txtNHS_post.Text
- ' Dim StrtxtYearQua As Integer = txtYearQua.Text
- conn = New SqlConnection(conStr)
- Dim UpdateStr As String = "update consultants SET Qualifications = @Qualifications where Dr_no = '" & ChkAuthID & "'"
- Dim cmd_Update As SqlCommand = New SqlCommand(UpdateStr, conn)
- cmd_Update.Parameters.Add(New SqlParameter("@Qualifications", StrtxtQua))
- Try
- cmd_Update.Connection.Open()
- cmd_Update.ExecuteNonQuery()
- cmd_Update.Connection.Close()
- goToStep = True ' This is a boolean Variable. Declared ealier
- Catch sqlEx As SqlException
- Response.Write("Error: SQL Exception Occured<br>")
- Catch ex As Exception
- Response.Write("Error: Unknown System Error Occured<br>")
- End Try
- If goToStep = True Then
- Response.Redirect("step_2.aspx")
- End If
- End Sub