Results 1 to 4 of 4

Thread: retrieve data without using dataset

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2003
    Posts
    18

    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')

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    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")

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    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 .

  4. #4
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256

    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
  •  



Click Here to Expand Forum to Full Width