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 separate 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??
- 01 Jul 2020
- 06 Apr 2020
- 11 Mar 2020
- 15 Feb 2020
- 02 Jan 2020
Recent on Build5Nines.com
Latest Cloud News: Azure Dev Guide eBook, xCloud, Cloud Shell + VNet and more! (August 11, 2020 – Build5Nines Weekly)11 Aug 2020
- 07 Aug 2020
Latest Cloud News: Azure Cloud Shell Tips, Azure Sphere, Microsoft acquire TikTok, NVidia acquire ARM, and more! (August 6, 2020 – Build5Nines Weekly)06 Aug 2020
- 01 Aug 2020
This site is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com. We also participates in affiliate programs with Udemy, and other sites. This site is compensated for referring traffic and business to these companies.