Advertisement

01.24.2008 at 02:36PM PST, ID: 23109540
[x]
Attachment Details

Change the Data type in the Data Set so that Excel sheet population works fine

Asked by techbie in Microsoft Visual C#.Net, .Net Editors & IDEs

Tags: Microsoft, ASP.net , C#.net, 2005

Hi experts,

I was asked to create a report in Excel. I should take data from a table and populate it on Excel.

I used the below query
select * from database_table;
 
Now in database there is a column name "ID" and its data type is  number.

Since some of the ID data is large, and after populating them in excel, they get converted to some different representation.

for example the value 9999999999999 in excel becomes
1E+13

I am asked to change the data type of this value to String in .net end, i.e they dont want me to use "select to_char(ID),.... from database_table". They wanna keep select * from database_table. but need to change the data type for column to string.

Any idea how do I do this. Is there a property like dataset.column.datatype = text

I think we can do it by changing the column property of the excel sheet to "General" or "Text".
But can this be done using .net side

Thanks very much,

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
this.sQuery="select * from database_table"
System.Data.
IDataReader IReader = objConn.ExecuteReaderII("SECURITY", this.sQuery, true);
System.Data.
 
DataSet obj = new System.Data.DataSet ();
obj.Load(IReader, System.Data.
 
LoadOption.OverwriteChanges, new string[] { "available" });
                                                      //need to change this obj dataset's ID column to string.
 
if (obj.Tables.Count > 0)
 
{
 
if (!Cache.ContainsKey("report"))
 
Cache.Add("report", obj);
 
else
 
Cache[
 
"report"] = obj;
}
[+][-]01.24.2008 at 09:46PM PST, ID: 20740398

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual C#.Net, .Net Editors & IDEs
Tags: Microsoft, ASP.net , C#.net, 2005
Sign Up Now!
Solution Provided By: anyoneis
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628