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

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

LVL 7
prosh0tAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
dstanley9Connect With a Mentor Commented:
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
 
prosh0tAuthor Commented:
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
 
prosh0tAuthor Commented:
i forgot to mention this is access 97

0
 
dstanley9Commented:
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
 
prosh0tAuthor Commented:
Thanks
0
All Courses

From novice to tech pro — start learning today.