Click here to Skip to main content
15,880,725 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm storing data into DataSet from excel file using Oledb provider in asp.net c# application.

query: SELECT * FROM [Sheet1$]

everything is working fine but my concern is that 1st row should be skiped and 2nd row should be used for heading and rest for datarow.

I need help on urgent basis.

thanks
Posted
Comments
[no name] 7-Apr-11 5:57am    
where is your connectionstring?

You could try defining the range. Something like:
SELECT * FROM [Sheet1$A2:X999]
 
Share this answer
 
Comments
trilokharry 8-Apr-11 1:02am    
thanks a lot.....
It's working fine.
Wendelius 8-Apr-11 1:29am    
Glad it helped :)
I believe thats not possible

Microsoft
With Excel workbooks, the first row in a range is the header row (or field names) by default. If the first range does not contain headers, you can specify HDR=NO in the extended properties in your connection string. If you specify HDR=NO in the connection string, the Jet OLE DB provider automatically names the fields for you (F1 represents the first field, F2 represents the second field, and so on).

MS Support[^]

However, you can do some fancy stuff by setting the HDR=NO, selecting all the records, and then from there, recreating the Dataset.
 
Share this answer
 
This might be useful to you. Excel With OLEDB
 
Share this answer
 
Please Explain your Question:

To Skip first certain no row you you can use this code to fill your dataset

OleDbDataAdapter da = new OleDbDataAdapter("Querytext",[Connectionobj]);
da.Fill(ds, startindex, MaxRecord, "name");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900