Click here to Skip to main content
15,928,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have an application by which a user enters his task in the form aft every specific time interval and the data entered is inserted into the excel sheet.The form has a link to the report of excel sheet where all the data is stored.so each time I m pressing the link,the data entered is getting multiplied.Is there anyway so that I can clear the excel sheet before I insert the data in my program.I have tried the sql queries like delete and updating each column to null.But none worked.plz help...
Thnx in advance.
Posted

1 solution

 
Share this answer
 
Comments
AC777 12-Aug-11 6:59am    
no it didnt work...I am using oledb connection for connecting to excel.My code for inserting the non repetitive tasks into the excel sheet is like this...


for (int i = 0; i < NonRepTasks.Count; i++)
{
sql = "Insert into [Sheet1$] values( '" + NonRepTasks[i] + "','"
+ FinalTime[i] + "','" + Completion[i] + "','" + Status[i] + "')";
myCommand.CommandText = sql;
myCommand.ExecuteNonQuery();
}

Tell me what I shud add b4 the for loop to clear my excel sheet 1 retaining the column names.
Wendelius 12-Aug-11 7:16am    
Ok, So if you're using Oledb have you tried updating every column to NULL before inserts. If I recall correctly DELETE won't work, but there's no harm in trying that also.
AC777 16-Aug-11 1:39am    
I have tried that too...it didnt work...shows a syntax error always even when my syntax is correct
Wendelius 17-Aug-11 11:39am    
Can you post the update statement and the full error message?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900