473,378 Members | 1,482 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,378 software developers and data experts.

Dataset problem


Dotnet v1.1

The following code creates a dataset with

- the correct number of rows
- the information in COL1 and COL2 are correct
- but the dataset only has 2 columns, COL1 and COL2
What is wrong??
Thank you,

John
private bool MakeDataset(SqlDataReader xReader)
{
bool result = false;
try
{
System.Web.HttpContext.Current.Session.Remove("MyD ataSet");
DataSet ds = new DataSet();
DataTable dt = new DataTable("MyData");
DataRow dr;
dt.Columns.Add(new DataColumn("COL1", typeof(Int32)));
dt.Columns.Add(new DataColumn("COL2", typeof(System.DateTime)));
dt.Columns.Add(new DataColumn("COL3", typeof(string)));
dt.Columns.Add(new DataColumn("COL4", typeof(string)));
dt.Columns.Add(new DataColumn("COL5", typeof(string)));
dt.Columns.Add(new DataColumn("COL6", typeof(string)));
dt.Columns.Add(new DataColumn("COL7", typeof(string)));
dt.Columns.Add(new DataColumn("COL8", typeof(System.DateTime)));

while (xReader.Read())
{
dr = dt.NewRow ();
dr["COL1"] = Convert.ToInt32(xReader.GetValue(0));
dr["COL2"] = Convert.ToDateTime(xReader.GetValue(1));
dr["COL3"] = xReader.GetValue(2).ToString();
dr["COL4"] = xReader.GetValue(3).ToString();
dr["COL5"] = xReader.GetValue(4).ToString();
dr["COL6"] = xReader.GetValue(5).ToString();
dr["COL7"] = xReader.GetValue(6).ToString();
dr["COL8"] = Convert.ToDateTime(xReader.GetValue(7));
dt.Rows.Add (dr);
}
ds.Tables.Add(dt);
System.Web.HttpContext.Current.Session["MyDataSet"] = ds;
result = true;
}
catch (Exception ex)
{
}
return result;
}
Sep 26 '06 #1
0 1114

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

Similar topics

6
by: Programatix | last post by:
Hi, I'm working on a project which includes WebServices and Windows Form application. The Windows Form application will call the WebServices to retrieve data from database. The data will be...
2
by: Programatix | last post by:
Hi, I'm working on a project which includes WebServices and Windows Form application. The Windows Form application will call the WebServices to retrieve data from database. The data will be...
2
by: theWizK | last post by:
Hello all. I have noticed that when I generate a strongly-typed dataset from an xml schema that the DataTables that are generated have their constructors marked as internal. What this means is...
4
by: Joerg M. Colberg | last post by:
Hi all, I have a problem when using a DataSet. I am using it to query a SQLServer database as follows. In my code it looks like SqlDataAdapter eDA = new SqlDataAdapter(sqlcmd); // where...
2
by: Dennis | last post by:
Hi, I am hoping I can get some help with a small problem I have run into using C#. U have an XML file that I load into a Dataset and then display this in a Datagrid. No problems doing this at all....
22
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to...
0
by: Bob Davies | last post by:
Hi I have a webservice that retrieves data from a database, this is then returned to the calling client application built in windows forms within a dataset, however upon attempting to create...
2
by: Carl Summers | last post by:
I have a table in an Access database that has no sort applied in Access. When I fill a dataset with data from that table (the entire one dimensional table) my dataset is sorted differently than...
17
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
8
by: Harry Strybos | last post by:
Visual Studio 2005 - SP1 - VB.Net on WinXP SP2 I add a typed dataset to my solution and get the following errors : Error 1 sub 'ReadXmlSerializable' cannot be declared 'Overrides' because it...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.