Why Fill creates two datatables in dataset?

Discussion in 'ASP .Net' started by John Sutter, Jan 12, 2004.

  1. John Sutter

    John Sutter Guest

    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.TableName; // for debugging purposes
    rowscount = dsDF.Tables.Rows.Count; // for debugging purposes

    }

    John
     
    John Sutter, Jan 12, 2004
    #1
    1. Advertising

  2. John Sutter

    Natty Gur Guest

    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.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!
     
    Natty Gur, Jan 13, 2004
    #2
    1. Advertising

  3. John Sutter

    John Sutter Guest

    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.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
     
    John Sutter, Jan 13, 2004
    #3
  4. John Sutter

    Natty Gur Guest

    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!
     
    Natty Gur, Jan 13, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Richard Loupatty
    Replies:
    2
    Views:
    382
    Richard Loupatty
    Jul 18, 2003
  2. Randy Smith
    Replies:
    1
    Views:
    488
    Marina
    May 9, 2005
  3. =?Utf-8?B?QWxleCBTIE1vb3Jl?=

    binding datalist to dataset with two datatables

    =?Utf-8?B?QWxleCBTIE1vb3Jl?=, Oct 7, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    3,147
    =?Utf-8?B?QWxleCBTIE1vb3Jl?=
    Oct 8, 2005
  4. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,270
    Smokey Grindel
    Dec 2, 2006
  5. Ron

    Populating DataSet from two DataTables

    Ron, Jul 15, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    205
    Alvin Bruney [MVP]
    Jul 18, 2004
Loading...

Share This Page