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

Problem Retrieving From Excel in C#

Hi all, Im using the following codes to retrieve records from excel file.

OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0 ; Data Source=" + Path + "; Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'");

OleDbCommand cmd = new OleDbCommand("SELECT TOP 10 * FROM [Sheet1$] WHERE [Project] <> ''", conn);

DataSet ds = new DataSet();
da = new OleDbDataAdapter(cmd);
da.Fill(ds);

DataTable table = ds.Tables[0];

In the excel file, there's a column storing values such as "IRAS 2009", "Nov-07" etc. When i retrieve from the DataTable it return me NULL and "31-Nov-07" respectively.

Why is it so? Why im unable to get the exact value and those in the excel file? Any help is greatly appreciated.
Oct 14 '09 #1
1 1786
GaryTexmo
1,501 Expert 1GB
I'm unsure about why "IRAS 2009" goes to NULL, but I'm pretty sure the date is a formatting thing. If it's an actual date in excel, then yea, your data table is just giving you a different format, but it's still the same date.

You can either change it to a string in excel, or format the date on output differently. The latter would probably be the better choice ;)
Oct 14 '09 #2

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

Similar topics

3
by: David | last post by:
Hi, Problem I have. We are trying out a new MRP system from 'www.caliach.com'. I am a web & database programmer, and usually code & maintain a large MS Access App via a back-end MySQL Server....
2
by: Chris Bellini | last post by:
Greetings! I'm developing a C# application that needs to read some data from a selected XLS file. I've used VB in the past to automate Excel but this is the first time I've used C#. Back in VB,...
2
by: Alex D. | last post by:
Hi .I cant seem to find a way to authorize asp.net user to create an Excel application using this: Microsoft.Office.Interop.Excel.ApplicationClass excel = new...
0
by: mihironline | last post by:
We have a scheduled job, which runs at every 5 min. As first step of this job, we are executing a stored proc. Inside stored proc, we have following line of code insert #exeResult EXEC...
2
by: navingautam | last post by:
i am developing my application in VS .NET 2.0 with C# as backend language. one of our web application uses COM objects to create excel files. The excel files thus created has to be printed. The...
0
by: thinkwebs | last post by:
Hi Guys Just i am trying to upload a excel sheet and read the data from excel sheet to database.it work properly while i run it in my program.but while i try to run in virtual folder or in web a...
1
by: rishiyo | last post by:
Good ones!! I want to retrieve and add datas with excel. I've tried one by adding two textboxes and two command buttons. THE code is: 'do declare these variables you need to add a reference'to...
2
by: Gilbert Tordeur | last post by:
Hello, My Web application in VB2008 with IIS calls Excel (2003) to create an Excel file xls. I use therefore Microsoft.Office.Interop.Excel, version 11. This application does not use anonymous...
2
by: shivapadma | last post by:
i am having one problem when i am retrieving data from Excel using vb.net following is the code Imports Microsoft.Office.Core Imports System.Runtime.InteropServices Imports System.Data.OleDb...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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:
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.