Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 C# DataSet Tables collection

Author  Topic 

Sitka
Aged Yak Warrior

571 Posts

Posted - 2003-08-19 : 13:32:12
Looked at a few thousand 'Select * from authors' examples and this result in....
dsBosstones.Table[0] == dsBosstones.Table["authors"]
fine but how is the table collection getting assigned...

the name "authors" I mean.... does

daBosstones.Fill(ds,"authors");
or
dscBosstones.FillDataSet(ds,"authors");

assign it at the time of the fill or is there an automation going on here because the command 'Select * from authors' comes uniquely from the authors table.

The model I'm searching for is a Stored procedure returning multiple sets to populate the tables collection. I got it to work using the wizard once in VS.NET result was TABLE and TABLE1 but when in manual mode It ain't jammin'. Can't get to the second or greater set dsBosstones.Table[1]

PS. thought by aliasing the final returned sets in the sproc there may be some level of getting control of this ie. naming the dsBosstones.Table[1] == dsBosstones.Table["secondsetalias"]
not there yet.

Voted best SQL forum nickname...."Tutorial-D"

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2003-08-19 : 13:46:36
Your code snippet:
daBosstones.Fill(ds,"authors");

runs whatever selectcommand text you've previously defined for the daBossTones data adapter and places the resultant rowset in a newly created table object added to the dataset's Tables collection.

If one rowset comes back, the table is inserted into the collection with key "authors". If more than one comes back, the key name provided gets a sequence # appended to it, e.g. authors0, authors1, etc.

Jonathan
{0}
Go to Top of Page

Sitka
Aged Yak Warrior

571 Posts

Posted - 2003-08-19 : 14:06:01
Ah shoot I kind of messed up the naming continuity but you understood...

So in general...

ds.Tables[0] == ds.Tables["authors0"]
ds.Tables[1] == ds.Tables["authors1"] etc.

Correct?



still thinking on this..(warning may seem ridiculous but it is because I'm ignorant.)

So what do I do to add a multiple rowsets to the DataSet that already
exists?

Like a desired result of...

ds.Tables[0] == ds.Tables["authors0"]
ds.Tables[1] == ds.Tables["authors1"]
ds.Tables[2] == ds.Tables["pubs0"]
ds.Tables[3] == ds.Tables["pubs1"]

^^^wicked awesome question.



Voted best SQL forum nickname...."Tutorial-D"
Go to Top of Page

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2003-08-19 : 15:02:34
Sitka-
Each DataAdapter:Fill() method appends Table objects to the Tables collection of the DataSet you specify, so the behaviour you're after is native. Calling Fill() multiple times with the same DataSet should give you what you want.

Jonathan
{0}
Go to Top of Page

Sitka
Aged Yak Warrior

571 Posts

Posted - 2003-08-19 : 16:06:17
Yee Haa, light bulb.
Thanks set' that rocks.




Voted best SQL forum nickname...."Tutorial-D"
Go to Top of Page
   

- Advertisement -