retrieve data without using dataset
Is there any way to retrieve data without using dataset? I need to run a select from an Access database, and the select command needs to join four table.
I was trying to create a dataset, but it always gives me errors when I tried create OleDbDataAdaper. I have run the sql query in access and the select command itself was OK. I guess the OleDbDataAdaper created errors when it was trying to generate updates command. I don't need to update the database, so I am just wondering if there is anyway that I could run select query and store the result somewhere without using dataset?
Here is the query:
SELECT
CMSContacts.LastNam,
CMSContacts.FirstNam,
CMSContacts.PhoneNum,
CMSContacts.FaxNum,
CMSContacts.EmailAddr,
CMSContacts.Street1Addr,
CMSContacts.Street2Addr,
CMSContacts.State,
CMSContacts.Zip
FROM
CMSContacts INNER JOIN
CMSPlanDesig ON
CMSContacts.ContKey = CMSPlanDesig.ContKey
INNER JOIN PlanStat ON
CMSPlanDesig.PlanID = PlanStat.PlanID
INNER JOIN Admin ON
PlanStat.AdminID = Admin.AdminID
WHERE
(Admin.FirstName <> 'John') OR (Admin.FirstName <> 'Kurt') OR (Admin.FirstName <> 'Lisa') OR (Admin.FirstName <> 'Debbie') OR (Admin.FirstName <> 'Terminated')
Re: retrieve data without using dataset
Quote:
Originally posted by peng90583
Is there any way to retrieve data without using dataset? I need to run a select from an Access database, and the select command needs to join four table.
I was trying to create a dataset, but it always gives me errors when I tried create OleDbDataAdaper. I have run the sql query in access and the select command itself was OK. I guess the OleDbDataAdaper created errors when it was trying to generate updates command. I don't need to update the database, so I am just wondering if there is anyway that I could run select query and store the result somewhere without using dataset?
Here is the query:
SELECT
CMSContacts.LastNam,
CMSContacts.FirstNam,
CMSContacts.PhoneNum,
CMSContacts.FaxNum,
CMSContacts.EmailAddr,
CMSContacts.Street1Addr,
CMSContacts.Street2Addr,
CMSContacts.State,
CMSContacts.Zip
FROM
CMSContacts INNER JOIN
CMSPlanDesig ON
CMSContacts.ContKey = CMSPlanDesig.ContKey
INNER JOIN PlanStat ON
CMSPlanDesig.PlanID = PlanStat.PlanID
INNER JOIN Admin ON
PlanStat.AdminID = Admin.AdminID
WHERE
(Admin.FirstName <> 'John') OR (Admin.FirstName <> 'Kurt') OR (Admin.FirstName <> 'Lisa') OR (Admin.FirstName <> 'Debbie') OR (Admin.FirstName <> 'Terminated')
What you need is a DataReader. Please not that the DataReader is a is foward only and you wont be able to bind it to a WinForms DataGrid.