Click here to Skip to main content
15,902,492 members
Home / Discussions / C#
   

C#

 
QuestionConvert HTML string to HtmlDocument Pin
zaboboa18-Dec-06 7:53
zaboboa18-Dec-06 7:53 
AnswerRe: Convert HTML string to HtmlDocument Pin
JMummery3-Dec-12 0:30
professionalJMummery3-Dec-12 0:30 
QuestionGet the appdomain by its friendly name. Pin
Prasadrn18-Dec-06 7:33
Prasadrn18-Dec-06 7:33 
QuestionASP.Net Question. Pin
hdv21218-Dec-06 6:48
hdv21218-Dec-06 6:48 
AnswerRe: ASP.Net Question. Pin
Prasadrn18-Dec-06 7:38
Prasadrn18-Dec-06 7:38 
GeneralRe: ASP.Net Question. Pin
hdv21218-Dec-06 8:50
hdv21218-Dec-06 8:50 
QuestionDataGridView - dragging multiple items with left mouse button Pin
Patrick Etc.18-Dec-06 5:52
Patrick Etc.18-Dec-06 5:52 
QuestionIssues with Converting IDataReader to DataSet Pin
DeepToot18-Dec-06 5:37
DeepToot18-Dec-06 5:37 
This is a 2005 project under 2.0
I am using Enterprise Library 2006
I am making a Select Call which returns an IDataReader.

I have checked the object after being populated and it seems to contain the information I need.

I go to convert it to a DataSet and it only shows the last item.

here is my Convert to DataSet code, I've tried numerous of examples found on the web, each one only returns the last record:

<br />
public static DataSet ConvertDataReadertoDataSet(IDataReader reader)<br />
{<br />
            DataSet ds = new DataSet();<br />
            DataTable schema;<br />
            DataTable data;<br />
            int i = 0;<br />
            DataRow dr;<br />
            DataColumn dc;<br />
            string columnName;<br />
            bool dun = false;<br />
            data = new DataTable();<br />
            schema = reader.GetSchemaTable();<br />
                  <br />
            do<br />
            {<br />
                if (schema != null)<br />
                {<br />
                    for (i = 0; i <= schema.Rows.Count - 1; i++)<br />
                    {<br />
                        dr = schema.Rows[i];<br />
                        columnName = dr["ColumnName"].ToString();<br />
                        if (data.Columns.Contains(columnName))<br />
                        {<br />
                            columnName = columnName + "_" + i.ToString();<br />
                        }<br />
                        if (columnName == "ID")<br />
                        {<br />
                            System.Type typeInt32 = System.Type.GetType("System.Int32");<br />
<br />
                            dc = new DataColumn(columnName, typeInt32);<br />
                        }<br />
                        else<br />
                        {<br />
                            System.Type typeString = System.Type.GetType("System.String");<br />
<br />
                            dc = new DataColumn(columnName, typeString);<br />
                        }<br />
                        <br />
                        <br />
                        data.Columns.Add(dc);<br />
                    }<br />
<br />
<br />
                    ds.Tables.Add(data);<br />
<br />
                    while (reader.Read())<br />
                    {<br />
                        dr = data.NewRow();<br />
                        for (i = 0; i <= reader.FieldCount - 1; i++)<br />
                        {<br />
                            dr[i] = reader.GetValue(i);<br />
                        }<br />
                        data.Rows.Add(dr);<br />
                    }<br />
                }<br />
                else<br />
                {<br />
                    dc = new DataColumn("RowsAffected");<br />
                    data.Columns.Add(dc);<br />
                    ds.Tables.Add(data);<br />
                    dr = data.NewRow();<br />
                    dr[0] = reader.RecordsAffected;<br />
                    data.Rows.Add(dr);<br />
                }<br />
<br />
            }while (reader.NextResult());<br />
<br />
            reader.Close();<br />
<br />
            return ds;<br />
        }



I f10'd through it and it seems to only be doing the 'do/while' once, the NextResult() is not going to the last record because it seems like its already at the last record.

Any suggestions or examples of another way of doing it would be great.

it needs to return a DataSet with multiple records.

Thanks


Steve Welborn
Software Engineer
BitWise Solutions

AnswerRe: Issues with Converting IDataReader to DataSet Pin
Colin Angus Mackay18-Dec-06 5:52
Colin Angus Mackay18-Dec-06 5:52 
GeneralRe: Issues with Converting IDataReader to DataSet Pin
DeepToot18-Dec-06 6:13
DeepToot18-Dec-06 6:13 
QuestionHow to create different versions/configurations in VS2005 Pin
frozenpondlife18-Dec-06 5:06
frozenpondlife18-Dec-06 5:06 
AnswerRe: How to create different versions/configurations in VS2005 Pin
ednrgc18-Dec-06 5:34
ednrgc18-Dec-06 5:34 
GeneralRe: How to create different versions/configurations in VS2005 Pin
frozenpondlife18-Dec-06 5:53
frozenpondlife18-Dec-06 5:53 
AnswerRe: How to create different versions/configurations in VS2005 Pin
Daniel Grunwald18-Dec-06 5:48
Daniel Grunwald18-Dec-06 5:48 
Questioni want code for authentication's to connect remote computer Pin
haneef118-Dec-06 4:29
haneef118-Dec-06 4:29 
AnswerRe: i want code for authentication's to connect remote computer Pin
ednrgc18-Dec-06 5:35
ednrgc18-Dec-06 5:35 
QuestionHow to Connect remoter computer i am getting exception error for remote as well as local computer Pin
haneef118-Dec-06 4:24
haneef118-Dec-06 4:24 
QuestionGet updated location for Control Pin
Tanuja12318-Dec-06 4:08
Tanuja12318-Dec-06 4:08 
Questionquery a datatable?? Pin
tadhg8818-Dec-06 3:52
tadhg8818-Dec-06 3:52 
AnswerRe: query a datatable?? Pin
J4amieC18-Dec-06 4:48
J4amieC18-Dec-06 4:48 
AnswerRe: query a datatable?? Pin
ToddHileHoffer18-Dec-06 4:49
ToddHileHoffer18-Dec-06 4:49 
GeneralRe: query a datatable?? [modified] Pin
tadhg8819-Dec-06 4:59
tadhg8819-Dec-06 4:59 
QuestionHow Can I Make Setup File In C#.NET 2003 Pin
kifahhk18-Dec-06 3:05
kifahhk18-Dec-06 3:05 
AnswerRe: How Can I Make Setup File In C#.NET 2003 Pin
led mike18-Dec-06 4:57
led mike18-Dec-06 4:57 
GeneralRe: How Can I Make Setup File In C#.NET 2003 Pin
ednrgc18-Dec-06 5:18
ednrgc18-Dec-06 5:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.