Sunday, 15 February 2015

c# - Default Equivalent to DBNull.Value -



c# - Default Equivalent to DBNull.Value -

i trying pass default sql server in c#.

this code passes null. there way pass default?

foreach (sqlparameter parameter in command.parameters) { if (convert.tostring(parameter.value) == "") { parameter.value = dbnull.value; } }

here solution of sorts -- appears search stored procedure parameter default values (literally, pattern search assignment in declaration of variable), , homecoming default values found. so...you phone call this procedure c# app of default values, assign them local c# vars, , utilize them when phone call other procedure.

http://www.codeproject.com/articles/12939/figure-out-the-default-values-of-stored-procedure

and here how find default value on table itself: (you might need strip parenthesis off returned value)

select column_default, replace(replace(column_default,'(',''),')','') defaultwithnoparenthesis information_schema.columns table_name = 'whatever'

good luck!

c# sql null default

No comments:

Post a Comment