sql server - SQL Exception Code -
i have been catching sql exception codes in c# using:
catch (sqlexception x) { console.writeline(x.message.tostring()); program.mylogfile("sql upload failed sql exception ", x.errorcode.tostring() +" ", today); } catch (exception ex) { console.writeline(ex.message.tostring()); program.mylogfile("sql upload failed exeption ", ex.message.tostring() + " ", today); email(); }
it gives me following number in text file. how can tell means?
error code: -2146232060 using sql 2012
consider using sqlexception.number property shown here: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlexception.number.aspx
also give better understanding of error message if query in sql server if want work 1 particular error code , something:
select * sysmessages
if @ error:104 above query , then: example if theres error union , order in sql:
catch (sqlexception e) { switch (e.number) { case 104: // something. break; default: throw; } }
Comments
Post a Comment