.NETGURU
DataReader / DataTable question...
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngdata' list.


Francesco Sanfilippo

I have a SQL sproc that returns 10 result sets. I grab it into a
DataReader. I want to loop through the result sets, and for each one, dump
the result set contents into a separate DataTable. I can't find a
DataReader equivalent to the DataAdapter Fill() method. Can someone show me
how this can be done?

TIA, Francesco

while (dr.read())
{
// loop through result sets and dump into DataTables
}

_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail.
http://www.hotmail.com

Reply to this message...
 
    
Sherlock Bryan P Contr OC-ALC/LIP
Try using NextResutl()

        Dim fNextResult As Boolean = True

        DataGrid1.DataSource = objDataReader
        DataGrid1.DataBind()
             
        fNextResult = objDataReader.NextResult()

        DataGrid1.DataSource = objDataReader
        DataGrid2.DataBind()

[Original message clipped]

-----Original Message-----
From: Francesco Sanfilippo [mailto:Click here to reveal e-mail address]
Sent: Monday, June 03, 2002 2:51 PM
To: aspngdata
Subject: [aspngdata] DataReader / DataTable question...

I have a SQL sproc that returns 10 result sets. I grab it into a
DataReader. I want to loop through the result sets, and for each one, dump
the result set contents into a separate DataTable. I can't find a
DataReader equivalent to the DataAdapter Fill() method. Can someone show me

how this can be done?

TIA, Francesco

while (dr.read())
{
// loop through result sets and dump into DataTables
}

_________________________________________________________________
Join the world's largest e-mail service with MSN Hotmail.
http://www.hotmail.com

| [aspngdata] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngdata.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

Reply to this message...
 
    
Alex Dresko
Perhaps this would help.
http://www.dotnetjunkies.com/tutorials.aspx?tutorialid=247

Alex Dresko
Three Point Oh!

-----Original Message-----
From: Francesco Sanfilippo [mailto:Click here to reveal e-mail address]
Sent: Monday, June 03, 2002 3:51 PM
To: aspngdata
Subject: [aspngdata] DataReader / DataTable question...

I have a SQL sproc that returns 10 result sets. I grab it into a
DataReader. I want to loop through the result sets, and for each one,
dump
the result set contents into a separate DataTable. I can't find a
DataReader equivalent to the DataAdapter Fill() method. Can someone
show me
how this can be done?

TIA, Francesco

while (dr.read())
{
// loop through result sets and dump into DataTables
}

_________________________________________________________________
Join the world's largest e-mail service with MSN Hotmail.
http://www.hotmail.com

| [aspngdata] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngdata.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

Reply to this message...
 
    
Michael Pizzo
Why are you getting back a DataReader? You can use Adapter.Fill in
order to populate multiple tables using the results from the Stored
Procedure. Using TableMappings in order to map the results to the
proper tables. For example:

SqlDataAdapter adapter =3D new SqlDataAdapter(
    "SP_GetCustomersAndOrders",cnn);
adapter.SelectCommand.CommandType =3D CommandType.StoredProcedure;
adapter.TableMappings.Add("Table1","Customer");
adapter.TableMappings.Add("Table2","Orders");
adapter.Fill(myDataSet);

-----Original Message-----
From: Francesco Sanfilippo [mailto:Click here to reveal e-mail address]=20
Sent: Monday, June 03, 2002 12:51 PM
To: aspngdata
Subject: [aspngdata] DataReader / DataTable question...

I have a SQL sproc that returns 10 result sets. I grab it into a=20
DataReader. I want to loop through the result sets, and for each one,
dump=20
the result set contents into a separate DataTable. I can't find a=20
DataReader equivalent to the DataAdapter Fill() method. Can someone
show me=20
how this can be done?

TIA, Francesco

while (dr.read())
{
// loop through result sets and dump into DataTables
}

_________________________________________________________________
Join the world's largest e-mail service with MSN Hotmail.=20
http://www.hotmail.com

| [aspngdata] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/asplists/aspngdata.asp =3D JOIN/QUIT
| http://www.asplists.com/search =3D SEARCH Archives

Reply to this message...
 
    
Francesco Sanfilippo
What if the DataTables aren't in a DataSet? Fill() doesn't work on
individual tables unfortunately.

FS

[Original message clipped]

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.

Reply to this message...
 
    
Francesco Sanfilippo
I did what you said, and I get an error that the DataSet cannot be null, on
the line where da.Fill() is attempted. What else do I need to do to
initialize it before Filling? I think it has to do with the source table
name. My sproc is returning a result set which is the result of a complex
join, it is not a simple SELECT * from a table, so the result set table
doesn't really have a name. Relevant code below...

TIA, Francesco

public DataSet MemberData;
SqlDataAdapter da = sql.ExecSPRetDA("Member_Initialize_All");
da.TableMappings.Add("PersonAddress","PersonAddress");
da.TableMappings.Add("PersonEmail","PersonEmail");
da.TableMappings.Add("PersonPhone","PersonPhone");
da.TableMappings.Add("PersonCommunity","PersonCommunity");
da.TableMappings.Add("PersonForum","PersonForum");
da.TableMappings.Add("PersonGallery","PersonGallery");
da.TableMappings.Add("PersonLanguage","PersonLanguage");
da.TableMappings.Add("PersonNewsletter","PersonNewsletter");
da.TableMappings.Add("PersonPerson","PersonPerson");
da.TableMappings.Add("PersonCategory","PersonCategory");
da.Fill(MemberData);

[Original message clipped]

_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com

Reply to this message...
 
 
System.Data.CommandType
System.Data.Common.DataAdapter
System.Data.DataSet
System.Data.DataTable
System.Data.SqlClient.SqlDataAdapter




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification