Step 1: Use Parameterized command in the cancellation webpage.
Step 2: Write the connection code in the click event of insert, update or delete button.
Step 3: Establish the connection using connection string.
Step 4: Create an object for sqlCommand .
Step 5: The command Statement contains the query with the parameters beginning with
‘@fieldname’.
‘@fieldname’.
Step 6: Add the parameters using Command object.parameters. Add with Value(“parameters”,
source).
source).
Step 7: Execute the command.
PROGRAM
VB CODE
Imports System.Data.Sql
Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim con As New SqlConnection(WebConfigurationManager.ConnectionStrings("kumaran").ConnectionString)
Dim cmd As New SqlCommand("delete from booking where ticket_no=@ticket_no", con)
cmd.Parameters.AddWithValue("@ticket_no", TextBox1.Text)
con.Open()
cmd.ExecuteNonQuery()
cmd.Connection.Close()
MsgBox("Canceled Successfully")
Response.Redirect("index.aspx")
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
End Class
0 comments:
Post a Comment