Bojan,
Thanks for the reply. I want the column names also. So, I figured out a different way where I am specifying the range in the dynamic query. I am making two roundtrips to the database.
1. First one gets the total number of records (SELECT num = COUNT(*) FROM [Sheet1$]) so that we can determine the last cell.
2. Second one gets the actual data with column names also. ("SELECT * FROM [Sheet1$A5:C" + (num+1).ToString() + "]")
Here A5 is the starting cell in the header row and C(num+1) is the last cell in the range. You have to specify the Extended Properties "HDR=Yes" in the connection string.
I'll update with the actual code later!
Thanks Basani
|