Upgraded to Office 2010, now ApplicationClass is error

Hello all

What is the best way (best practice) to preserve my NULL SQL values in the database
during an insert/update operation (without receiving cast invalid errors)?
Also, how to display a string ‘n/a’ when a sql value is NULL?

My project is using FormView with Edit/Insert templates and classes to represent my tables

Goal1….: display ‘n/a’ when there are NULL SQL values in the database
Solution1: I am using ISNULL(field,”) in my store procedure for SELECT statements

Goal2….: if the fields are ‘n/a’, then save them back in the database as NULL
Solution2: on my insert/edit methods I am having to check the values being passed, i.e:

cmd.Parameters.Add(new SqlParameter(“@scope”, SqlDbType.NVarChar, 50));

if (item.Scope == “n/a”)
 cmd.Parameters[“@scope”].Value = DBNull.Value;
 cmd.Parameters[“@scope”].Value = item.Scope;

Not to mention that for SQL DateType fields when you use ISNULL(field,”) the return string is ‘1/1/1900 12:00:00 AM’
and I have to change the field value in every field that represents a date, i.e:

protected void FormView1_DataBound(object sender, System.EventArgs e)  
    Label LabelDate = FormView1.FindControl(“lblDate”) as Label;  
    if (LabelDate.Text == “1/1/1900 12:00:00 AM”) {  
        LabelDate.Text = “n/a”;  

and to store NULL in a datatime sql field I do:

SqlDateTime sqldatenull;
cmd.Parameters [“@Date”].Value =sqldatenull ;

That (in my opinion) is a lot of code change in many different places.
Am I reinventing the wheel? Am I doing it wrong or following the worst approach here?

Please shed some light 🙂

Thank you


maximusmd:display ‘n/a’ when there are null  SQL values  in the databaseyou have to use ISNULL function to return  certain value  when the column is nullISNULL(columnName,’n/a’) columnNamemaximusmd: if the fields  are ‘n/a’, then save  them back  in the database  as NULLpass the value as it is and in procedure  you can use a case statement and insertsomething like thisinsert into testtable

– The first comment was a typo; I am actually using ISNULL(field,’n/a’).- I do like the idea of using the CASE statement so I can update everything in one place.- ISNULL(datefield,’n/a’) wont work because my class field  is of DateTime type;I thought ther