Private Sub ShowData()
Dim sql As String = ""
sb.Remove(0, sb.Length())
sb.Append("SELECT RentDetail.RentID, RentDetail.FameID, Fame.FameName, Fame.Category, Customer.CusName, Rent.RentDate, Rent.ReturnDate, Rent.RentStatus ")
sb.Append(" FROM RentDetail,Fame,Rent,Customer")
sb.Append(" WHERE RentDetail.FameID=Fame.FameID")
sb.Append(" AND RentDetail.RentID=Rent.RentID")
sb.Append(" AND Rent.CusID=Customer.CusID")
'sb.Append("SELECT RentDetail.RentID, RentDetail.FameID, Fame.FameName, Fame.Category, Rent.RentDate FROM RentDetail INNER JOIN Fame ON (RentDetail.FameID=Fame.FameID) INNER JOIN Rent ON (Rent.RentID = RentDetail.RentID)")
'sb.Append(" INNER JOIN Rent ON RentDetail.RentID=Rent.RentID")
sql = sb.ToString
If IsFind = True Then
ds.Tables("RentDetail").Clear()
End If
da = New OleDbDataAdapter(sql, Conn)
da.Fill(ds, "RentDetail")
If ds.Tables("RentDetail").Rows.Count <> 0 Then
IsFind = True
With dgvFile
.ReadOnly = True
.DataSource = ds.Tables("RentDetail")
End With
Else
IsFind = True
dgvFile.DataSource = Nothing
MessageBox.Show("ไม่พบรายการในฐานข้อมูล", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
FormatDatagrid()
End Sub
Tag : .NET, Ms Access, VB.NET, VS 2008 (.NET 3.x), VS 2010 (.NET 4.x), Windows