Solved

ADO.NET - Populating multi-table dataset in MS Access

Posted on 2007-03-22
5
357 Views
Last Modified: 2008-09-12
Hello,

I'm trying to figure out how to populate a dataset with 2 tables in ADO.NET.  The code below should work but it doesn't.  It throws an exception at the line 'da.Fill(dSetWF)' saying 'Characters found after end of SQL statement.'  I believe this is because microsoft Access doesn't allow multi statement queries.  What is the best way to accomplish what I am trying to do?

Thanks.

Here is my code:

dSetWF = new DataSetWorkflow();  //dSetWF is a typed dataset

OleDbDataAdapter da = new OleDbDataAdapter("select * from workflow; select * from comments;", cnWF);
da.TableMappings.Add("Table", "Workflow");
da.TableMappings.Add("Table1", "Comments");
da.Fill(dSetWF);

0
Comment
Question by:prosh0t
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 25

Accepted Solution

by:
dstanley9 earned 500 total points
ID: 18773198
Two separate queries?

dSetWF = new DataSetWorkflow();  //dSetWF is a typed dataset

OleDbDataAdapter daWorkflow = new OleDbDataAdapter("select * from workflow", cnWF);
OleDbDataAdapter daComments = new OleDbDataAdapter("select * from comments", cnWF);
daWorkflow.Fill(dSetWF.Workflow);
daComments.Fill(dSetWF.Comments);

0
 
LVL 7

Author Comment

by:prosh0t
ID: 18773342
i was just hoping there was a more elegant way to do keep this confined to 1 data adapter... is this impossible with ms access?




0
 
LVL 7

Author Comment

by:prosh0t
ID: 18773349
i forgot to mention this is access 97

0
 
LVL 25

Expert Comment

by:dstanley9
ID: 18773399
I don't believe the JET driver supports batch queries.

From http://msdn2.microsoft.com/en-us/library/aa832700(office.10).aspx:

"Access databases cannot return multiple Recordset objects because Microsoft Jet SQL statements do not support multiple SELECT statements."

This is in reference to ADO but it will apply to ADO.NET as well
0
 
LVL 7

Author Comment

by:prosh0t
ID: 18773821
Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question