asp.net mvc - C# to stored procedure error trapping -


in c# mvc app using stored procedure pass multiple values database.

db.database.executesqlcommand("exec ......     , new sqlparameter("@nametitle", sessionvalues.employee.title.ordbnull())     , new sqlparameter("@initials", sessionvalues.employee.initials.ordbnull())     , new sqlparameter("@forename", sessionvalues.employee.forename.ordbnull())     , new sqlparameter("@mondaystart", sessionvalues.workpattern.mondaystart.nulldt()) 

the context ordbnull , nulldt

public static class myclassordbnull {     public static object ordbnull(this string s)     {         return string.isnullorempty(s) ? dbnull.value : (object)s;     }      public static object nulldt(this datetime? x)     {         return !x.hasvalue ? dbnull.value : (object)x;     } }   

i'm getting stack overflow errors , because stored procedure passes in 50 parameters hard work out issue is.

one issue getting

arithmetic overflow error converting expression data type nvarchar

which think issuing passing null mondaystart date section. stored procedure accept null though.

commented out , error:

server error in '/' application.

error converting data type nvarchar tinyint.

description: unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code.

exception details: system.data.sqlclient.sqlexception: error converting data type nvarchar tinyint.

is there better trap these expose parameter failing on?


Comments