Solved

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

Posted on 2007-03-22
5
331 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
  • 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Coding C# in Linux 8 60
designing in object programming 12 75
JQuery JavaScripot loop though RadioButtonList 4 23
Send SMS from VB via Sierra Wireless Modem 2 21
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now