How would insert a row into an excel document. This is what I have.
String connString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + file_path + ";Extended Properties=Excel 8.0;";
DataTable dt = new DataTable();
DataSet ds = new DataSet();
OleDbConnection conn = new OleDbConnection(connString);
OleDbCommand cmd = new OleDbCommand(str_insert, conn);
cmd.CommandTimeout = 3600;
try
{
cmd.Connection = conn;
DataSet active_ds = new DataSet();
cmd.CommandText = str_insert;
if (conn.State != ConnectionState.Open)
conn.Open();
foreach (DataRow dr in details_dt.Rows)
{
cmd.CommandText = "INSERT INTO [DETAILS$](Ipt, Ipt Ownr, Order, Order Delivery Date, Assembly, Description, Component, User, Name, Change Code, Reason Code, Value New, Value Old,"
+ "Date, Time, Auth Doc, Plant, Mfg Source, Order Type, Model, Effy) " + "VALUES(" + dr.ItemArray[0].ToString() + "," + dr.ItemArray[1].ToString() + "," + dr.ItemArray[2].ToString() + "," + dr.ItemArray[3].ToString() + "," +
dr.ItemArray[4].ToString() + "," + dr.ItemArray[5].ToString() + "," + dr.ItemArray[6].ToString() + "," + dr.ItemArray[7].ToString() + "," + dr.ItemArray[8].ToString() + "," + dr.ItemArray[9].ToString() + "," + dr.ItemArray[10].ToString()
+ "," + dr.ItemArray[11].ToString() + "," + dr.ItemArray[12].ToString() + "," + dr.ItemArray[13].ToString() + "," + dr.ItemArray[14].ToString() + "," + dr.ItemArray[15].ToString() + "," + dr.ItemArray[16].ToString() + "," + dr.ItemArray[17].ToString()
+ "," + dr.ItemArray[18].ToString() + "," + dr.ItemArray[19].ToString() + "," + dr.ItemArray[20].ToString() + "," + dr.ItemArray[21].ToString() + ")";
cmd.ExecuteNonQuery();
}
PLEASE HELP thanks!!!
SOLVED!!!