|
-
Jul 11th, 2003, 08:02 PM
#1
Thread Starter
Junior Member
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')
-
Jul 11th, 2003, 08:27 PM
#2
PowerPoster
The IDE is nice for simple stuff, but if you have more complex stuff, it isn't always going to work. Use this code to fill a dataset from your select statement (I didn't verify it runs, I did it from memory):
Code:
Dim conn As New OleDbConnection("connectionstring")
Dim command As New OleDbCommand("Your Select Statement", conn)
Dim ds As New DataSet()
Dim da As New OleDbDataAdapter();
conn.Open()
da.SelectCommand = command
da.Fill(ds,"MyTable")
-
Jul 11th, 2003, 09:25 PM
#3
Sleep mode
I believe you can do it with DataReader object which return the execution of OleDbCommand . I can't give you sample though , I have serious problems with my dev computer .
-
Jul 11th, 2003, 09:25 PM
#4
Frenzied Member
Re: retrieve data without using dataset
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|