PDA

View Full Version : DateSet Filtering


emvanlill
03-24-04, 02:39 PM
Hello
I'm doing a select query from two tables, but I want to show only the last 10 recors in this selection inside a DataGrid.
I've created a OleDbDataAdapter and used a SQL query with a LIMIT clause in it, but the data does not want to load into the DataSet.

Do I have to filter the DataSet?

Code:

Dim dbAdapter As OleDbDataAdapter = New OleDbDataAdapter("Select VisitsLog.ApplicantID, ApplicantsDetails.AppName, ApplicantsDetails.AppSurname, VisitsLog.DateVisit from VisitsLog, ApplicantsDetails Where VisitsLog.ApplicantID = ApplicantsDetails.ApplicantID", conn)
Dim DataSet_VisitLog As DataSet = New DataSet
conn.Open()
dbAdapter.Fill(DataSet_VisitLog)
conn.Close()
'Filter DataSet
Grid_LogVisits.DataSource = DataSet_VisitLog.Tables(0).DefaultView

Thanks
Emile

cassasm
04-14-04, 12:47 PM
I think that you need to include that table name in the fill method. Example: dbAdapter.Fill(DataSet_VisitLog, "tablename") -should be in quotes. I hope this helps. If so then please see if you can be of assistance with my filtering post.
Cassasm


Hello
I'm doing a select query from two tables, but I want to show only the last 10 recors in this selection inside a DataGrid.
I've created a OleDbDataAdapter and used a SQL query with a LIMIT clause in it, but the data does not want to load into the DataSet.

Do I have to filter the DataSet?

Code:

Dim dbAdapter As OleDbDataAdapter = New OleDbDataAdapter("Select VisitsLog.ApplicantID, ApplicantsDetails.AppName, ApplicantsDetails.AppSurname, VisitsLog.DateVisit from VisitsLog, ApplicantsDetails Where VisitsLog.ApplicantID = ApplicantsDetails.ApplicantID", conn)
Dim DataSet_VisitLog As DataSet = New DataSet
conn.Open()
dbAdapter.Fill(DataSet_VisitLog)
conn.Close()
'Filter DataSet
Grid_LogVisits.DataSource = DataSet_VisitLog.Tables(0).DefaultView

Thanks
Emile