1
Answer

Insert null value using limq to sql

Fathy Geaiessah

Fathy Geaiessah

11y
1.3k
1

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)