onez

onez

  • NA
  • 73
  • 0

Excel Database - Inserting Rows

Aug 16 2004 3:02 PM
I am trying to create a database with Excel becuase ADO.net and MS Access do not work on my computer. Has anyone else had problems using ADO.net and VS 2005 beta? I am trying to insert rows into a worksheet. I can use the source code from a tutorial at this site or the Microsoft website. The problem is I can only insert one row. If I try to insert another row it tries to insert the data at the same row and causes an error. I tried adjusting the size and other properties of the Name - Define field in excel. Making the size taller just causes the data to be inserted below the area and then the same error will occur. Is there a way to make the rows be inserted one after another? Is there a way to insert a row at a customized spot? Thanks. System.Data.OleDb.OleDbConnection objConn = new System.Data.OleDb.OleDbConnection( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\EasyAccess\\DbExcel.XLS;" +"Extended Properties=Excel 8.0;"); objConn.Open(); System.Data.OleDb.OleDbCommand objCmd = new System.Data.OleDb.OleDbCommand(); objCmd.Connection = objConn; objCmd.CommandText = "Insert into StockList (Symbol, Company)" + " values ('TTT', 'Test"')"; objCmd.ExecuteNonQuery(); objCmd.CommandText = "Insert into StockList (Symbol, Company)" + " values ('XYZ', 'ExWhyZee')"; objCmd.ExecuteNonQuery(); // ERROR - "program needs to shut down..." objConn.Close();