try
{
//KOPIOR TILL EXCEL
string path2XLS = "MinExcelRapport_copy_"+counter+".xls";
string excelDocPath = @"MinExcelRapport.xls";
string excelDocPath2 = @"path2XLS";
System.IO.File.Copy(excelDocPath,excelDocPath2,true);
// Establish a connection to the data source.
System.Data.OleDb.OleDbConnection objConn = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + excelDocPath2 + ";Extended Properties=\"Excel 8.0;HDR=NO;\"");
objConn.Open();
// Add some records to excel.
System.Data.OleDb.OleDbCommand objCmd = new System.Data.OleDb.OleDbCommand();
objCmd.Connection = objConn;
if(inID.ToString()!="")
{
objCmd.CommandText = "UPDATE serialNo SET F1='" + inID + "'";
objCmd.ExecuteNonQuery();
}
if(OutprodNR.ToString()!="")
{
objCmd.CommandText = "UPDATE prodNum SET F1='" + OutprodNR + "'";
objCmd.ExecuteNonQuery();
}
if(prob_finder!="")
{
objCmd.CommandText = "UPDATE probfinder SET F1='" + prob_finder + "'";
objCmd.ExecuteNonQuery();
}
if(OutSTATE.ToString()!="")
{
objCmd.CommandText = "UPDATE state SET F1='" + OutSTATE + "'";
objCmd.ExecuteNonQuery();
}
if(OutWeek.ToString()!="")
{
objCmd.CommandText = "UPDATE Week SET F1='" + OutWeek + "'";
objCmd.ExecuteNonQuery();
}
if(today!="")
{
objCmd.CommandText = "UPDATE now_date SET F1='" + today + "'";
objCmd.ExecuteNonQuery();
}
if(faultDes!="")
{
objCmd.CommandText = "UPDATE fault_info SET F1='" + faultDes + "'";
objCmd.ExecuteNonQuery();
}
// Close the connection.
objConn.Close();
}
catch (System.Exception exut)
{
label1.Text="Somthing went wrong in copying to excel, " + exut;
}