Hi, You have missing HDR property in your connection string. http://www.connectionstrings.com/excel "HDR=Yes;" indicates that the first row contains columnnames, not data. "HDR=No;" indicates the opposite.
If I misunderstood you, please feel free to tell me. On Jul 2, 5:16 pm, Matteo <[email protected]> wrote: > Hi all. > i want to insert a new row in an empty .xlsx file via SQL > instructions.. > This is the code : > > 'Dim MyConnection As System.Data.OleDb.OleDbConnection > 'Dim MyCommand As New System.Data.OleDb.OleDbCommand > 'MyConnection = New System.Data.OleDb.OleDbConnection > ("provider=Microsoft.ACE.OLEDB.12.0;Data 'Source='c: > \modello.xlsx';Extended Properties=Excel 8.0;") > 'MyConnection.Open() > 'MyCommand.Connection = MyConnection > 'MyCommand.CommandTimeout = 0 > 'MyCommand.CommandText = "Insert into [Foglio1$] values > ('aa','cc','sd','kk')" > 'MyCommand.ExecuteNonQuery() > 'MyConnection.Close() > > My problem is that when the compiler try to add the new row, he > doesn't konw where to put them because he doesn't know the name of the > coloum in the .xlsx file( that Is empty). > Instead if in the file there is already a row.. it works!!, only if > the number of the cell filled(in the first row) is the same of the > parameters that i want to write(those of sql instructions , Insert > into [Foglio1$] values ('aa','cc','sd','kk') ).. > > thanks in advance > Matteo.
