Click here to Skip to main content
15,920,576 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I'm stroing 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 from 1st row to 7th row should be skiped and 8th row should be used for heading and rest for datarow.

I need help on urgent basis.

Thanks
Mohan
Posted

It's not something that I have done before, but had a read of this thread here:

http://stackoverflow.com/questions/4929217/openrowset-for-excel-can-we-skip-several-rows[^]

Although neither response is marked as a solution it could be worth trying them.
 
Share this answer
 
Comments
CHill60 5-Jun-13 9:05am    
My +5 ... I've used ranges like this before to do something similar
Pheonyx 5-Jun-13 9:06am    
Thanks :)
Hello Mohan,

You have to retrive only those records from database and then bind into excel sheet. e.g.
SQL
DECLARE @From = 7;
DECLARE @To = SELECT COUNT(*) FROM MyTable;
WITH NumberedMyTable AS
(
    SELECT
        Id,
        Value,
        ROW_NUMBER() OVER (ORDER BY Id) AS RowNumber
    FROM
        MyTable
)
SELECT
    Id,
    Value
FROM
    NumberedMyTable
WHERE
    RowNumber BETWEEN @From AND @To
 
Share this answer
 
Comments
V Mohan 5-Jun-13 8:56am    
Thanks Suna,

I have bulk data in my excel sheet.From that excel sheet only i need to be copy data and store in SQL table. How i can read data from Excel to sql server

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