sql server - How to catch SQLException in C#? -
here tried catch sql exception using innerexception in smo ojects.in sqlserver getting error message
msg 121, level 15, state 1, procedure test_sp_syntaxtext, line 124 select list insert statement contains more items insert list.
but using code
catch (exception ex) { errorflag = true; //ex.source.tostring(); e2dinsertandgenerateerrorlog(ex.innerexception.message.tostring(), filename, "checkinapply", pathname, "errorlog.err"); }
i getting
the select list insert statement contains more items insert list.
i need cache line also
msg 121, level 15, state 1, procedure test_sp_syntaxtext, line 124
any suggestion?
edit:
streamreader str = new streamreader(filetextbox.text.tostring()); string script = str.readtoend(); str.dispose(); sqlconnection conn = new sqlconnection("data source=xx;database=xxx;user id=sx;password=xxxx"); server server = new server(new serverconnection(conn)); server.connectioncontext.executenonquery(script);
use sqlexception.
catch (sqlexception ex) { (int = 0; < ex.errors.count; i++) { errormessages.append("index #" + + "\n" + "message: " + ex.errors[i].message + "\n" + "linenumber: " + ex.errors[i].linenumber + "\n" + "source: " + ex.errors[i].source + "\n" + "procedure: " + ex.errors[i].procedure + "\n"); } console.writeline(errormessages.tostring()); }
Comments
Post a Comment