Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Data.SqlClient
- Imports System.Data
- Public Class Form1
- Dim con As New SqlConnection("Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=databse2;Integrated Security=True")
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- Dim cmd As New SqlCommand("insert into customer values(@cid , @cname , @dob,@gender,@city)", con)
- cmd.Parameters.AddWithValue("@cid", TextBox1.Text)
- cmd.Parameters.AddWithValue("@cname", TextBox2.Text)
- cmd.Parameters.AddWithValue("@dob", TextBox3.Text)
- cmd.Parameters.AddWithValue("@gender", TextBox3.Text)
- cmd.Parameters.AddWithValue("@city", TextBox3.Text)
- cmd.ExecuteNonQuery()
- MsgBox("your data Submit successfully")
- End Sub
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- 'TODO: This line of code loads data into the 'Database23DataSet.customer' table. You can move, or remove it, as needed.
- Me.CustomerTableAdapter1.Fill(Me.Database23DataSet.customer)
- con.Open()
- End Sub
- Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
- Dim adpt As New SqlDataAdapter("select * from customer", con)
- Dim ds As New DataSet()
- adpt.Fill(ds, "jadu")
- DataGridView1.DataSource = ds
- DataGridView1.DataMember = "jadu"
- End Sub
- Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
- Dim cmd As New SqlCommand("update customer set cname = @cname , City = @City where cid = @cid ", con)
- cmd.Parameters.AddWithValue("@cid", TextBox1.Text)
- cmd.Parameters.AddWithValue("@cname", TextBox2.Text)
- cmd.Parameters.AddWithValue("@City", TextBox3.Text)
- cmd.ExecuteNonQuery()
- MsgBox("your data Updated successfully")
- Dim adpt As New SqlDataAdapter("select * from customer", con)
- Dim ds As New DataSet()
- adpt.Fill(ds, "jadu")
- DataGridView1.DataSource = ds
- DataGridView1.DataMember = "jadu"
- End Sub
- Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
- Dim cmd As New SqlCommand("delete from customer where cid=@cid", con)
- cmd.Parameters.AddWithValue("@cid", TextBox1.Text)
- cmd.ExecuteNonQuery()
- MsgBox("your data Delete successfully")
- Dim adpt As New SqlDataAdapter("select * from customer", con)
- Dim ds As New DataSet()
- adpt.Fill(ds, "jadu")
- DataGridView1.DataSource = ds
- DataGridView1.DataMember = "jadu"
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement