Private Sub frmListAllProducts_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Windows.Forms.Cursor.Current = Cursors.WaitCursor
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
Dim sqlBook As String = ""
sqlBook = "SELECT t_Product.Product_id, t_Product.Product_name, t_Product.Product_Brand,"
sqlBook &= " t_Product.Product_Price, t_Product.Product_Detail, t_Product.Product_Total"
sqlBook &= " FROM t_Product"
'sqlBook &= " WHERE(Book.BookTypeCode = BookType.BookTypeCode)"
'sqlBook &= " AND (Book.BookStatus='1')"
If IsFind = True Then
ds.Tables("t_Product").Clear()
End If
da = New OleDbDataAdapter(sqlBook, Conn)
da.Fill(ds, "t_Product") ' erorr บรรทัดนี้นะค่ะ
If ds.Tables("t_Product").Rows.Count <> 0 Then
IsFind = True
With grdProducts
.AllowNavigation = False
.ReadOnly = True
.DataSource = ds.Tables("t_Product")
End With
Else
IsFind = False
grdProducts.DataSource = Nothing
End If
FormatDataGridWithData()
Windows.Forms.Cursor.Current = Cursors.Default
End Sub
Option Explicit On
Option Strict On
Imports System.Data
Imports System.Data.OleDb
Public Class frmListAllProducts
Inherits System.Windows.Forms.Form
Const DATABASE_FILE As String = "C:\\Database\\Pharmacy.mdb"
Dim strConnection As String = " Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & DATABASE_FILE
Dim Conn As New OleDbConnection(strConnection)
'Dim Conn As OleDbConnection = New OleDbConnection()
Dim da As OleDbDataAdapter
Dim ds As DataSet = New DataSet
Dim IsFind As Boolean = False
Dim ToClose As Boolean = False
Private Sub frmListAllProducts_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Windows.Forms.Cursor.Current = Cursors.WaitCursor
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With