Programming for Everybody: delete
Showing posts with label delete. Show all posts
Showing posts with label delete. Show all posts

Insert,Update and Delete Statements in SQL Server

INSERT INTO table_name (column1, column2, column3, ...)VALUES (value1, value2, value3, ...);


UPDATE table_name
SET column1 = value1, column2 = value2, ... WHERE condition;



DELETE FROM table_name WHERE condition;












insert update delete data in datagridview without using database in visual basic.net




Imports System.Data.DataTable
Public Class Form2
    Dim table As New DataTable("table")
    Dim index As Integer





    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        table.Columns.Add("ID", Type.GetType("System.Int32"))

        table.Columns.Add("First name", Type.GetType("System.String"))

        table.Columns.Add("Last name", Type.GetType("System.String"))

        table.Columns.Add("Sum", Type.GetType("System.Int32"))


        DataGridView1.DataSource = table







    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        table.Rows.Add(TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text)

        DataGridView1.DataSource = table




    End Sub

   

  

   

    
    Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick

        index = e.RowIndex

        Dim selectedrow As DataGridViewRow


        selectedrow = DataGridView1.Rows(index)



        TextBox1.Text = selectedrow.Cells(0).Value.ToString


        TextBox2.Text = selectedrow.Cells(1).Value.ToString


        TextBox3.Text = selectedrow.Cells(2).Value.ToString



        TextBox4.Text = selectedrow.Cells(3).Value.ToString














    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        Dim newdata As DataGridViewRow


        newdata = DataGridView1.Rows(index)


        newdata.Cells(0).Value = TextBox1.Text

        newdata.Cells(1).Value = TextBox2.Text


        newdata.Cells(2).Value = TextBox3.Text



        newdata.Cells(3).Value = TextBox4.Text
















    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Text = ""


        TextBox2.Text = ""



        TextBox3.Text = ""



        TextBox4.Text = ""







    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        DataGridView1.Rows.RemoveAt(index)








    End Sub
End Class