I want to add rows in a DataSet, but only a specific number of rows (in order to avoid the “Too many fields defined.” exception). This is what I have tried so far:
OleDbCommand command = new OleDbCommand(@"SELECT TOP 100 FROM [" + SheetName + "]", connection);
Exception: The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.
OleDbCommand command = new OleDbCommand(@"SELECT * FROM [" + SheetName + "] LIMIT 100", connection);
Exception: Syntax error in FROM clause.
I also tried this that I got from another site
OleDbCommand command = new OleDbCommand(@"SELECT TOP 100 * FROM [" + SheetName + "]", connection);
Exception: Too many fields defined.
I have no idea what else to try, any suggestions?
You can specify how many rows you would like the
Fill()method to retrieve. Here’s its signature from MSDN:http://msdn.microsoft.com/en-us/library/0z5wy74x.aspx