Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am getting foll error:
table 'Claim_Resets' already exists.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()

code written:

string connect_excel = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\Nas00276pn\x990\Claims Repricing\CLAIMS REPRICING\PSL3\Daily Checks\Daily Resets\Daily Reset Files\Daily Resets AM " + filedatesave + ".xls;Mode=ReadWrite;Extended Properties='Excel 12.0;HDR=Yes'";
                OleDbConnection conn_excel = new OleDbConnection(connect_excel);
                conn_excel.Open();
                Trace.WriteLine("Excel connection successful" + DateTime.Now);

DbCommand gen_excel = new OleDbCommand("Create table [Claim_Resets]([Reset_Tab] string,[ppoONE_Claim_ID] string,[Tax_ID] string,[Date_Entered] string,[Client_ID] string,[Policy1] string)", conn_excel);
                gen_excel.ExecuteNonQuery();


What I have tried:

it was executing fine since 2 yrs... suddenly see this error today.
Posted
Updated 23-Jan-17 6:27am
Comments
[no name] 23-Jan-17 12:28pm    
"it was executing fine since 2 yrs, suddenly see this error today", then something changed. You need to find out what changed and then deal with it. The error message is perfectly clear.
Member 12963977 23-Jan-17 13:55pm    
Nothing has been changed as a different .exe having same coding but running for another script and file is working completely fine.

1 solution

I can't say what's been happening for the last two years, but the error is valid and accurate. Maybe this is the first time the file has been processed twice or before the table was removed?
Just update the code to check if the table exists first:

I was gonna write it out but it's solved over here:
Reading Excel sheet name with characters[^]
 
Share this answer
 
Comments
Member 12963977 23-Jan-17 13:53pm    
I am creating a new excel everytime here...
filedatesave represent datetime stamp and thatswhy it needs to be hard coded.

Moreover I terminated all sessions and executed it again but getting same error. To be more precise I have similar coding for a different file and its working.

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