473,461 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Idatareader string values

I am reading an excel file using ADO.Net. In a column, my first value is nothing and the rest of the values are numbers. But when I read values, I am getting all empty strings. If I replace my first value with some random number, then I am able to read all the values.

My assumption is that IDataReader is detecting the type by its first value and applying it to rest of the values. Is there a way to tell it to assume everything to be strings? Or any other solution to this problem. (Note: I gottu use DataReader because a lot of the logic in the base classes is based on it and I cannot change it.)

[code]
while (dreader.Read())
{
if (ProcessRecord(dreader))
bError = true;
}


ProcessRecord(IDataReader dr)
{
string value = dr.GetValue(0).ToString();
}
[code]
Sep 17 '08 #1
1 1476
balabaster
797 Expert 512MB
I don't know for sure, but I recall that Excel has the same issue when you import files into it. It uses the first few lines to determine the data type and if your data type changes outside those first few lines you're hooped. I can't say for sure that this is the same root cause, but it might be worth investigation to rule it out...
Sep 17 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Vivek Sharma | last post by:
Hi There, can some one please clarify the difference between SQLDataReader and IDataReader? What are the advantages and disadvantages of each? Thanks Vivek
5
by: Gelios | last post by:
Hello All! I am going to crazy and feeling myself so stupid but I don't understand such behaviour. I have code: public int getNextAgentId() { Int32 agent_id = 0; IDataReader dr =...
4
by: Mahesh Kumar.R | last post by:
What is the difference between SqlDataReader and IDataReader ...? kindly with small example... Mahesh~
3
by: js | last post by:
Hi, I want to debug the return idatareader, how to print out some fields value? many thanks.
2
by: יוני גולדברג | last post by:
Hi, In few places within my code the business object pass IDataReader to the GUI. Suddenly i noticed that nowhere in the code the IDataReader is being closed. Does the data binding operation...
2
by: Larry R | last post by:
Whenever I try the following, the reader that is returned is always closed. What am I missing ? When I look at the reader in the ExecuteReader, it is fine. THen it gets closed on the returm. ...
0
by: rsdev | last post by:
Hi, I am new to ASP.NET and I am trying to build a CMS application using theBeerHouse SK. I am adapting the Datareader to collect information from an SQL database and send it to an HtmlHeader. ...
2
by: RP | last post by:
I saw a code in a class where IDataReader is used to retrieve result from query, even if only one column is to be retrieved. It uses a CommandObject with ExecuteReader but not using ExecuteScalar....
1
parshupooja
by: parshupooja | last post by:
Hey All, I have 2 IDatareaders. forex: Idatareader r One Two Three Four Idatareader a One
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.