Ex. Multiple table in 1 Dataset

Imports System.Data
Imports System.Data.OleDb

Public Class frmCustomer
Dim Conn As OleDbConnection = New OleDbConnection
Dim da As OleDbDataAdapter
Dim ds As DataSet = New DataSet
Dim CurrentRow As New Integer

Private Sub frmCustomer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With

Dim sqlCustomer As String = "SELECT * FROM Customers"
da = New OleDbDataAdapter(sqlCustomer, Conn)
da.Fill(ds, "Customer")

With dtgCustomer
.DataSource = ds.Tables("Customer")
End With

Dim sqlCreditCard As String = "SELECT * FROM CreditCards"
da = New OleDbDataAdapter(sqlCreditCard, Conn)
da.Fill(ds, "CreditCard")

With cboCreditCard
.DataSource = ds.Tables("CreditCard")
.ValueMember = "card_id"
.DisplayMember = "card_Names"
End With

End Sub

Private Sub dtgCustomer_CellEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dtgCustomer.CellEnter

CurrentRow = dtgCustomer.CurrentRow.Index
txtCustFirstName.Text = dtgCustomer.Item(2, CurrentRow).Value.ToString

With cboCreditCard
.SelectedValue = dtgCustomer.Item(12, CurrentRow).Value.ToString
End With

Dim gender As New Char
gender = dtgCustomer.Item(9, CurrentRow).Value.ToString
If gender = "M" Then
radMale.Checked = True
radFemale.Checked = False
Else
radMale.Checked = False
radFemale.Checked = True
End If
End Sub

Private Sub txtSearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearch.TextChanged
Dim sqlSearch As String
sqlSearch = "SELECT * FROM Customers"
sqlSearch &= " WHERE c_fname LIKE '%" & txtSearch.Text.Trim & "%' "
sqlSearch &= " OR c_lname LIKE '%" & txtSearch.Text.Trim & "%' "

da = New OleDbDataAdapter(sqlSearch, Conn)
ds.Reset()
da.Fill(ds, "dsSearch")

With dtgCustomer
.DataSource = ds.Tables("dsSearch")
End With
End Sub

Private Sub btnPopUp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPopUp.Click, dtgCustomer.CellContentDoubleClick
tmpCustID = dtgCustomer.Item(0, CurrentRow).Value

Dim frmMainPopup As mainpopup = New mainpopup
frmMainPopup.ShowDialog(Me)

End Sub

Private Sub dtgCustomer_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles dtgCustomer.KeyUp
If e.KeyCode = Keys.Enter Then
tmpCustID = dtgCustomer.Item(0, CurrentRow).Value

Dim frmMainPopup As mainpopup = New mainpopup
frmMainPopup.ShowDialog(Me)
End If
End Sub
End Class

Post has attachment

Post has attachment

Post has attachment
คำร้องขอสอบ 5 บท
แก้ไขปีการศึกษา และชื่อหัวหน้าโปรแกรม ก่อนพิมพ์

Post has attachment
ตัวอย่างระบบเพื่อนเจ้าสาว

Post has attachment

Post has attachment

Post has attachment
ตัวอย่างระบบจองชุดครุบ ของ มรภ.รำไพพรรณี

Post has attachment

Post has attachment
ตัวอย่าง ร้านเช่าชุด พอดี พอใจ
Wait while more posts are being loaded