none
Multiple Query RRS feed

  • Question

  • Hi,

     

    I need to read two select query from MS Access Database. How can I do this through OleDB?

     

    Thank's

    Alexei

    Monday, September 17, 2007 8:05 AM

Answers

  • Hi,

     

    I am looking for reading data from diferent tables. This is not same data!!!!!!

     

    So I have found solution:

    1. Create DataSet and add the titles of table.

    2. Create first adapter with first select and file the dataset with specified table.

    3. Create second adapter with second select and file the dataset with specified table.

    and etc.

     

    It works fine.

     

    Thank's

    Alexei

    Tuesday, September 18, 2007 1:58 PM

All replies

  • Could you provide a bit more information?

     

    You can combine two SELECT queries using the UNION keyword but I'm not sure if that is what you are looking for.

     

    Monday, September 17, 2007 1:37 PM
  • Hi,

     

    I am looking for reading data from diferent tables. This is not same data!!!!!!

     

    So I have found solution:

    1. Create DataSet and add the titles of table.

    2. Create first adapter with first select and file the dataset with specified table.

    3. Create second adapter with second select and file the dataset with specified table.

    and etc.

     

    It works fine.

     

    Thank's

    Alexei

    Tuesday, September 18, 2007 1:58 PM
  • You could also have put both selects into one DataAdapter, separated by semi-colons.

     

    Code Snippet

    SELECT * FROM FirstTable; Select * FROM SecondTable

     

     

    Then, when you do

     

    Code Snippet

    MyDataAdapter.Fill(MyDataSet)

     

     

    it should fill both tables of the DataSet.

     

    I should note that I know this will work for SQL Server, but I'm not sure if the same applies to Access. Someone please correct me if I'm wrong.

    Wednesday, September 19, 2007 4:03 AM
  • Yes, it will work for SQL Server but multiple SELECT statements are not supported by Jet OLEDB.

     

    Wednesday, September 19, 2007 11:56 AM
  • Thanks Paul ... I wasn't sure about that. Now I know.

    Friday, September 21, 2007 4:07 PM