Public Class Form1
Friend cn As New SqlConnection("Data sources=.\SQLExpress; Initial Catalog=stocktest;Integrated Security=sspi;")
Friend cmd As New SqlCommand
Friend DA As New SqlDataAdapter
Friend DS As New DataSet
Friend sql As String
Public Sub open_database()
If cn.State = ConnectionState.Closed Then cn.Open()
End Sub
Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
open_database()
sql = "select * from product"
DA = New SqlDataAdapter(sql, cn)
DS = New DataSet
DA.Fill(DS, "table")
DataGridView1.DataSource = DS.Tables("table")
End Sub
End Class
Tag : .NET, Ms SQL Server 2012, Web (ASP.NET), VB.NET