asp.net - Usp_updateXXXX is throwing has too many arguements -
we working on deadlock issue , went solution catching deadlock exception , resubmitting 6 times. users happy didnt errors new error thrown after 2 hours moved production below error "usp_updatexxxx throwing has many arguements" . issue happening whenever app encounters deaadlock exception.
please find code snippet below { //msg = string.empty;
sqlconnection _con = new sqlconnection(conn); sqlcommand _cmd = new sqlcommand(); sqldataadapter _adp = new sqldataadapter(_cmd); _cmd.connection = _con; bool isdeadlock = false; int retry = 0; //check deadlock , retry 6 times send same request { msg = string.empty; seek { _con.open(); _cmd.commandtype = commandtype.storedprocedure; _cmd.commandtext = "usp_updatexxxx"; //assign command parametrs _cmd.executenonquery(); isdeadlock = false; } grab (exception ex) { if ((ex.message.contains("was deadlocked on lock resources process , has been chosen deadlock victim")) || (ex.message.contains("deadlock")) || (ex.message.contains("transaction (process id"))) { isdeadlock = true; thread.sleep(5000); retry++; } else { msg = ex.message; isdeadlock = false; } } { con.close(); } } while (retry < 6 && isdeadlock == true);
can 1 help me code bug causing throw exception.
regards prashant
the issue happened because of looping used. when exception happens 1 time again going phone call loop without clearing existing parameters hence adding new parameters .
to resolve issue cleared parameters 1 time in exception section.
try{ //statements here } grab (exception ex) { if ((ex.message.contains("was deadlocked on lock resources process , has been chosen deadlock victim")) || (ex.message.contains("deadlock")) || (ex.message.contains("transaction (process id"))) { //used below statement command.parameters.clear() ; isdeadlock = true; thread.sleep(5000); retry++; } else { msg = ex.message; isdeadlock = false; } }
this resolved prob.
regards prashant
asp.net sql-server-2008 exception stored-procedures
No comments:
Post a Comment