Microsoft Most Valuable Professional

Chris Pietschmann

An MVP From Wisconsin



Fill DataSet with multiple Tables and update them with DataAdapter

One way to fill a DataSet with multiple tables is to send the database multiple requests. Another way to do this is to use multiple SELECT statements in a single request.

There are a couple of problems with doing it this way:

  • The DataTables don't have the same name as the tables in the database, you have to set them yourself
  • You can't update/save the tables to the database; to do that you must use a seperate DataAdapter for each table.

Dim myAdapter as SqlDataAdapter = new SqlDataAdapter(
      “
SELECT * FROM Customers; SELECT * FROM Orders“, connection)

myAdapter.Fill(dsTables)
dsTables.Tables(0).TableName = “Customers“)
dsTables.Tables(1).TableName = “Orders“)

It would be so much easier if they made it so you can use the same DataAdapter to update all the tables you load into the DataSet with the DataAdapter.

If you do try to update all the tables with the same DataAdapter, then you will get an error like the one below (this error really frustrated me for a couple hours):

An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll

Additional information: Missing the DataColumn 'Date' in the DataTable 'FeeChargeAttendance' for the SourceColumn 'Date'.

 

I wonder if Mono has this same issue??

Currently rated 3.7 by 3 people

  • Currently 3.666667/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: General
Posted by crpietschmann on Sunday, August 22, 2004 11:48 PM
Permalink | Comments (2) | Post RSSRSS comment feed

Related posts

Comments

sauravmay das

Tuesday, August 16, 2005 7:20 AM

sauravmay das

i also facing same problem..please give answer for that

antony

Wednesday, July 19, 2006 11:54 AM

antony

Thank you so much. I looked for the reading issue for days.

Comments are closed

About the author

I'm Chris Pietschmann, go to the About Me page to learn more about me.

Search

Sponsors

Web.Maps.VE - ASP.NET AJAX Virtual Earth Mapping Server Control

Recent comments

Disclaimer


This work is licensed under a Creative Commons Attribution 3.0 United States License, unless explicitly stated otherwise within the posted content.
© Copyright 2004 - 2008 Chris Pietschmann