March 30, 2015

Visual Studio Activity2

Imports System.Data.SqlClient
Public Class Form1
    Dim con As SqlConnection = New SqlConnection("Data Source=.\sqlexpress;Initial Catalog=Mynewdatabase;Integrated Security=True;Pooling=False")
    Dim cmd As SqlCommand

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim ds As New DataSet
        Dim da As SqlDataAdapter
        cmd = New SqlCommand("Select Customer_ID, P_roduct_name, Order_ID, Quantity from OrderTable where Customer_ID=('" & TextBox1.Text & "')", con)
        con.Open()
        da = New SqlDataAdapter(cmd)
        da.Fill(ds)
        DataGridView1.DataSource = ds.Tables(0)
        con.Close()


    End Sub
End Class

No comments: