Programming for Everybody: Insert button database access vb.net

Insert button database access vb.net

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\gamal\Pictures\aa.mdb")
        Dim cmd As New OleDbCommand("", conn)
        cmd.CommandText = "insert into table1(firstname,lastname,country,tel)values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "')"
        conn.Open()
        cmd.ExecuteNonQuery()
        conn.Close()

        ' Refresh Datagridview
        Me.Table1TableAdapter.Fill(Me.AaDataSet1.Table1)

    End Sub

No comments:

Post a Comment