Friend Sub loadrecord()
Try
OpenDatabase()
Dim oleDBC As New SqlCommand
Dim oleDBDR As SqlDataReader
Dim c As Integer
c = 0
With oleDBC
.Connection = Connt
.CommandText = "SELECT dt,No,typ,typ_l,typ_e,LAK,THB,USD,EUR,Total_lak,rec FROM DCS_SPH_Mny_payuot Where No='" & txtNo.Text & "'"
End With
oleDBDR = oleDBC.ExecuteReader
DGV.Rows.Clear()
If oleDBDR.HasRows Then
While oleDBDR.Read
DGV.Rows.Add()
dtg.Value = oleDBDR.Item(0)
txtNo.Text = oleDBDR.Item(1)
DGV.Item(2, c).Value = oleDBDR.Item(2)
DGV.Item(3, c).Value = oleDBDR.Item(3)
DGV.Item(4, c).Value = oleDBDR.Item(4)
DGV.Item(5, c).Value = oleDBDR.Item(5)
DGV.Item(6, c).Value = oleDBDR.Item(6)
DGV.Item(7, c).Value = oleDBDR.Item(7)
DGV.Item(8, c).Value = oleDBDR.Item(8)
DGV.Item(9, c).Value = oleDBDR.Item(9)
DGV.Item(10, c).Value = oleDBDR.Item(10)
c = c + 1
End While
DGV.Columns("LAK").DefaultCellStyle.Format = "#,##0.00"
DGV.Columns("USD").DefaultCellStyle.Format = "#,##0.00 "
DGV.Columns("THB").DefaultCellStyle.Format = "#,##0.00"
DGV.Columns("EUR").DefaultCellStyle.Format = "#,##0.00 "
Exit Sub
End If
Catch ex As Exception
End Try
End Sub
Code (code ดืงข้อมุล Table2)
Friend Sub loadrecord1()
Try
OpenDatabase()
Dim oleDBC1 As New SqlCommand
Dim oleDBDR1 As SqlDataReader
Dim c1 As Integer
'Dim ds As DataSet
'Dim sql As String
' con.ConnectionString = str
c1 = 0
With oleDBC1
.Connection = Connt
.CommandText = "SELECT rec FROM DCS_amt Where No1='" & txtNo.Text & "'"
End With
oleDBDR1 = oleDBC1.ExecuteReader
DGV.Rows.Clear()
If oleDBDR1.HasRows Then
While oleDBDR1.Read
' DGV.Rows.Add()
DGV.Item(11, c1).Value = oleDBDR1.Item(0)
c1 = c1 + 1
End While
Else
Exit Sub
End If
Catch ex As Exception
MsgBox(Err.Description)
End Try
End Sub