1
Reply

Insert null value using limq to sql

Fathy Geaiessah

Fathy Geaiessah

Oct 17 2013 4:48 AM
952

Hi every body

I am trying to insert values using linq to sql through textboxes some of these textboxes may contain null values how to insert null values without exception, for example:

{

tblUser u=new tblUser;

u.Name=txt1.text;

u.Mobile=txt2.text;

db.tblUsers.InsertOnSubmit(u);

db.SubmitChanges();
}

if txt1 or txt2 is empty how to avoid exception and insert the null value?

 


Answers (1)