Posted by: Sourav | June 1, 2015

Delete Data from SQL Server Using VB.Net

Delete using

Add another page

Rename the page of tab control as Delete

Add a label


Make the text “So who you want to delete”

Make the text larger


Add a button and make it’s name delete


Add this sub on your sqlcon.vb


Public Sub dataupdate(query As String)



           sqlcommand = New SqlCommand(query, sqlcon)

           Dim change As Integer = sqlcommand.ExecuteNonQuery







           If change = 0 Then

               MsgBox(“you haven’t found what you where looking for”)


               MsgBox(change & ” rows affected”)


           End If



       Catch ex As Exception


           If sqlcon.State = ConnectionState.Open Then


           End If

       End Try

   End Sub



The code for delete button is




If TextBox7.Text <> “” Then

           If MsgBox(“Do you really want to delete ” & TextBox7.Text & ” ?”, MsgBoxStyle.YesNoCancel) = MsgBoxResult.Yes Then

               sqlcon.dataupdate(“Delete from test where Name = ‘” & TextBox7.Text & “‘”)



           End If

       End If


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


%d bloggers like this: