tags:

views:

80

answers:

2

Hi all.

Can anybody help me? How can I read only first row from an Excel file with OleDbDataAdapter?

I know how I can read all data from any spread sheet:

var dataAdapter = new OleDbDataAdapter("SELECT * FROM [" + sheetName + "$]", oledbConnection);

But I don't know how can I do this for one row.

+1  A: 
select top 1 * from ... 
gsharp
Very nice solution. Great. Thanks.
misho
that's just very basic sql actually ;-)
gsharp
A: 

You can refer to a range:

var dataAdapter = new OleDbDataAdapter("SELECT * FROM [" + sheetName + "$A1:C2]", oledbConnection);
Remou
Thanks very much
misho