01.
Public
Class
Form1
02.
Friend
cn
As
New
SqlConnection(
"Data sources=.\SQLExpress; Initial Catalog=stocktest;Integrated Security=sspi;"
)
03.
Friend
cmd
As
New
SqlCommand
04.
Friend
DA
As
New
SqlDataAdapter
05.
Friend
DS
As
New
DataSet
06.
Friend
sql
As
String
07.
08.
Public
Sub
open_database()
09.
If
cn.State = ConnectionState.Closed
Then
cn.Open()
10.
11.
End
Sub
12.
13.
Private
Sub
DataGridView1_CellContentClick(sender
As
Object
, e
As
DataGridViewCellEventArgs)
Handles
DataGridView1.CellContentClick
14.
15.
End
Sub
16.
17.
Private
Sub
Form1_Load(sender
As
Object
, e
As
EventArgs)
Handles
MyBase
.Load
18.
open_database()
19.
sql =
"select * from product"
20.
DA =
New
SqlDataAdapter(sql, cn)
21.
DS =
New
DataSet
22.
DA.Fill(DS,
"table"
)
23.
DataGridView1.DataSource = DS.Tables(
"table"
)
24.
25.
26.
End
Sub
27.
End
Class