on-internet
← Community

How to insert data into excel using OleDbConnection

Stack Overflow ·

I have a excel file and defined two column Date,Result in it. I want insert data in it with c#. I use this code : string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + System.AppDomain.CurrentDomain.BaseDirectory + "\\Data\\sms log.xlsx;Extended Properties=Excel 12.0;"; OleDbConnection myConnection = new OleDbConnection(connectionString); if(myConnection.State==System.Data.ConnectionState.Closed) myConnection.Open(); OleDbCommand myCommand = new System.Data.OleDb.OleDbCommand(); myCommand.Connection = myConnection; myCommand.CommandText =string .Format( "Insert into TABL

Comments

Sign in or sign up to comment and upvote.

No comments yet.