System.Data.OleDb.OleDbConnection MyConnection ; System.Data.DataSet DtSet ; System.Data.OleDb.OleDbDataAdapter MyCommand ; MyConnection = new System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source='c:\\csharp.net-informations.xls';Extended Properties=Excel 8.0;"); MyCommand = new System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", MyConnection); MyCommand.TableMappings.Add("Table", "TestTable"); DtSet = new System.Data.DataSet(); MyCommand.Fill(DtSet); dataGridView1.DataSource = DtSet.Tables[0]; MyConnection.Close(); http://csharp.net-informations.com/excel/csharp-excel-oledb.htm hope it will help you. maaki.
** On Friday, August 17, 2012 9:33:07 PM UTC+5:30, crocboy25 wrote: > Hello Group, > > I am selecting rows from an excel spreadsheet. In the spreadsheet I have > like 2000+ rows, sometimes even more. When I run a spreadsheet it always > stop reading the rows on line number 899. I have checked the data on the > row, the row before and after and nothing seems out of the ordinary that > would make it stop. Only 7 columns of small amounts of data per column. > Any idea why the reader would stop on a particular line and not move > forward? It doesnt error out but when I check data adapter after it > executes it only has like 895 records(the first 4-5 lines in excel are used > as headers on my spreadsheets). I tried it with both an xls file and a xlsx > file with the same results. Any idea what could be causing this? Thanks for > any assistance. > > The string variable strConnection is set to ..... > Provider= Microsoft.ACE.OLEDB.12.0;Data > Source=c:\excel\upload\9907USS103402.XLSX; Extended Properties="Excel > 12.0;HDR=NO;IMEX=1;"; > > Dim pobjDataAdapter As OleDbDataAdapter > > pobjDataAdapter = New OleDbDataAdapter("select * from LASPBS",strConnection > ) > -- You received this message because you are subscribed to the Google Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting" group. To post to this group, send email to dotnetdevelopment@googlegroups.com To unsubscribe from this group, send email to dotnetdevelopment+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en or visit the group website at http://megasolutions.net