Imports System.Data.SqlClient
Public Class Form1
Dim con As SqlConnection = New SqlConnection("Data Source=.\sqlexpress;Initial Catalog=FinalExamination;Integrated Security=True;Pooling=False")
Dim cmd As SqlCommand
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub Label6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label6.Click
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
cmd = New SqlCommand("Insert into Customer_Table values('" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "')", con)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
Display()
End Sub
Public Sub Display()
Dim ds As New DataSet
Dim da As SqlDataAdapter
cmd = New SqlCommand("Select * from Customer_Table", con)
con.Open()
da = New SqlDataAdapter(cmd)
da.Fill(ds)
DataGridView1.DataSource = ds.Tables(0)
con.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
cmd = New SqlCommand("Insert into Product_Table values('" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & "')", con)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
Display1()
End Sub
Public Sub Display1()
Dim ds As New DataSet
Dim da As SqlDataAdapter
cmd = New SqlCommand("Select * from Product_Table", con)
con.Open()
da = New SqlDataAdapter(cmd)
da.Fill(ds)
DataGridView2.DataSource = ds.Tables(0)
con.Close()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
cmd = New SqlCommand("Insert into Order_Table values('" & TextBox12.Text & "')", con)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
Display2()
End Sub
Public Sub Display2()
Dim ds As New DataSet
Dim da As SqlDataAdapter
cmd = New SqlCommand("Select * from Order_Table", con)
con.Open()
da = New SqlDataAdapter(cmd)
da.Fill(ds)
DataGridView3.DataSource = ds.Tables(0)
con.Close()
End Sub
End Class
No comments:
Post a Comment