Private Sub frmProduct_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
strConn = "Data Source = .\SQL2008; Integrated Security = True; Initial Catalog = Community; Persist Security Info = True"
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
ShowData()
ShowDept()
SaveCancel()
End Sub
Private Sub frmBalance_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\s\Desktop\Community\Database\Community.mdb; Persist Security Info=False;"
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
ShowData()
End Sub
Option Explicit On
Option Strict On
Imports System.Data
Imports System.Data.SqlClient
Public Class frmBalance
Dim strConn As String
Dim Conn As New SqlConnection
Dim da As SqlDataAdapter
Dim ds As New DataSet
Dim strSQL As String
Dim IsFind As Boolean
Private Sub FormatGrd()
With grdProduct
If .RowCount <> 0 Then
.Columns(0).HeaderText = "รหัส"
.Columns(1).HeaderText = "สินค้า"
.Columns(2).HeaderText = "ราคาทุน"
.Columns(3).HeaderText = "ราคาขาย"
.Columns(4).HeaderText = "จุดสำรอง"
.Columns(5).HeaderText = "คงเหลือ"
.Columns(6).HeaderText = "ประเภท"
.Columns(0).Width = 60
.Columns(1).Width = 200
.Columns(2).Width = 80
.Columns(3).Width = 80
.Columns(4).Width = 80
.Columns(5).Width = 70
.Columns(6).Width = 100
End If
End With
End Sub
Private Sub ShowData()
strSQL = "SELECT * FROM Product"
da = New SqlDataAdapter(strSQL, Conn)
If IsFind = True Then
ds.Tables("Product").Clear()
End If
da.Fill(ds, "Product")
If ds.Tables("Product").Rows.Count <> 0 Then
grdProduct.DataSource = ds.Tables("Product")
FormatGrd()
IsFind = True
End If
End Sub
Private Sub frmBalance_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
strConn = "Data Source = .\SQL2008; Integrated Security = True; Initial Catalog = Community; Persist Security Info = True"
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
ShowData()
End Sub
Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAdd.Click
ShowData()
End Sub
End Class
Option Explicit On
Option Strict On
Imports System.Data
Imports System.Data.OleDb
Public Class frmBalance
Dim strConn As String
Dim Conn As New OleDb.OleDbConnection
Dim da As OleDb.OleDbDataAdapter
Dim ds As New DataSet
Dim strSQL As String
Dim IsFind As Boolean
Private Sub FormatGrd()
With grdProduct
If .RowCount <> 0 Then
.Columns(0).HeaderText = "รหัส"
.Columns(1).HeaderText = "สินค้า"
.Columns(2).HeaderText = "ราคาทุน"
.Columns(3).HeaderText = "ราคาขาย"
.Columns(4).HeaderText = "จุดสำรอง"
.Columns(5).HeaderText = "คงเหลือ"
.Columns(6).HeaderText = "ประเภท"
.Columns(0).Width = 60
.Columns(1).Width = 200
.Columns(2).Width = 80
.Columns(3).Width = 80
.Columns(4).Width = 80
.Columns(5).Width = 70
.Columns(6).Width = 100
End If
End With
End Sub
Private Sub ShowData()
strSQL = "SELECT * FROM Product"
da = New OleDbDataAdapter(strSQL, Conn)
If IsFind = True Then
ds.Tables("Product").Clear()
End If
da.Fill(ds, "Product")
If ds.Tables("Product").Rows.Count <> 0 Then
grdProduct.DataSource = ds.Tables("Product")
FormatGrd()
IsFind = True
End If
End Sub
Private Sub frmBalance_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source = C:\Community\Database\Community.mdb; Persist Security Info=False"
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
ShowData()
End Sub
Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAdd.Click
ShowData()
End Sub
End Class