473,322 Members | 1,911 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Why Fill creates two datatables in dataset?


The first iteration in the loop in the code below creates two datatables.
This is unexpected as I am expecting one called Table0.
(The SqlDataAdapter uses a stored procedure which returns a single
resultset. dsDF is a variable of a dataset class which has an xsd file)

When I checked the tablename of the first table, it had the name of the
stored procedure instead of "Table0" which went to the second table
instead. Is this normal behavior? I might be missing a simple fact.
(rowcount for first table is 0)

code snippet:

for (int i =0; i < 6; i++) {
this.sqlDataAdapter1.Fill(dsDF, "Table" + i.ToString());
tablename = dsDF.Tables[i].TableName; // for debugging purposes
rowscount = dsDF.Tables[i].Rows.Count; // for debugging purposes

}

John
Nov 18 '05 #1
3 1271
Hi,

I think that you are not using the fill method right. The second
parameter should be the source (DB) TableName. Your code should be like
that:

for (int i =0; i < 6; i++) {
this.sqlDataAdapter1.Fill(dsDF, "DbTableName");
dsDF.Tables[i].TableName = "Table" + i.ToString()
}

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2
On Mon, 12 Jan 2004 23:09:37 -0800, Natty Gur wrote:
Hi,

I think that you are not using the fill method right. The second
parameter should be the source (DB) TableName. Your code should be like
that:

for (int i =0; i < 6; i++) {
this.sqlDataAdapter1.Fill(dsDF, "DbTableName");
dsDF.Tables[i].TableName = "Table" + i.ToString()
}


The second parameter is the name of the datatable AFAIK. If your select or
stored procedure comes from seevral tables, what would be the name of the
second parameter if it's the name of a database table?

John
Nov 18 '05 #3
Hi,

I'm not DataSet expert, in fact i dislike datasets :-). Check out the
code that i post, i check it up and it works as expected.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tee | last post by:
Hi, I need some help about filling dataset, I am not sure how to describe it, so I give the example here. da = new OleDbDataAdapter("SELECT * FROM Path WHERE PathID=1", cnn); ...
0
by: Steve | last post by:
C# Is it possible to fill 2 different DataTables with one DataAdapter? I have a dataset comprising 2 tables, one is the child table of the other. Then my dataAdapter is configured something...
10
by: dauphian | last post by:
Hello, I am new to .net and am trying to build a report application that queries 4 different tables based on a id, and I need to return them in the same table for easy viewing. Basically, I...
4
by: Cindy H | last post by:
Hi I'm using an access database and vb.net I have been using the following type of function to get data from one table. This is working great - Public Shared Function GetAllLotsForSale()...
5
by: Monty M. | last post by:
Hello; I was wondering if anyone can assist me with this problem. Here are the tools I am using: Language: C# Database: MS SQL Server 2000 Application: Visual Studio 2005 1. I have a...
0
by: mike1402 | last post by:
Hi ! I get the error below sometimes when retrieving a big amount of data using Datadapter.Fill(dataset,"table"). But when I send the command Fill again, there is no error. Is it a fault of...
2
by: slinky | last post by:
I'm getting a error when I open my . aspx in my browser... line 34: da.Fill(ds, "Assets") Here's the error and my entire code for this .aspx.vb is below that ... I need some clues as to what is...
1
by: Probi | last post by:
HI, I have a DropDownList populated from database I use the following code OracleDataAdapter ad2 = new OracleDataAdapter(cmd2, connection); DataSet ds2 = new DataSet(); ad2.Fill(ds2); ...
0
by: StefanPienaar | last post by:
Hi Guys Is there any way in c# (or vb.net) to extract a datatable of data from a dataset with multiple datatables which has relationships set up (containing combined data from the datatables)? ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.