Click here to Skip to main content
15,921,990 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi ,

i have created a store procedure and used taht store procedure to insert data to table.But it create problem when the int or datetime text value is null.How do i handle it?

the code is in below

C#
 DATAClassesDataContext db = new DATAClassesDataContext();

 int result = db.insertagent(txtagent.Text, txtfather.Text, Convert.ToDateTime(txtdob.Text), txtaddress.Value, Convert.ToInt32(txtpin.Text),
  Convert.ToInt32(txtage.Text), txtphoneno.Text, txtbankname.Text,
Convert.ToInt32(txtaccountno.Text), txtbankaddress.Value, txtpancardno.Text, txtnominee.Text, rbtrelationship.Text, Convert.ToInt32(txtNomineeage.Text), txtIntroducernamet.Text, Convert.ToInt32(txtIntroducercode.Text),
                                       txtrank.Text, Convert.ToInt32(txtissuerank.Text), Convert.ToInt32(txtcustomerid .Text), txtpalnbname.Text,
                                      Convert.ToInt32(txtplanbcode.Text), txtteama.Text, txtteamb.Text, txtepinno.Text, txtserialno.Text, Convert.ToDateTime(txtfromdate.Text),
                                       txtemail.Text);



Thanks in Advance!!!!!!!!!!
Posted
Updated 18-Aug-11 20:53pm
v2

1 solution

Check them. Or write generic methods which return either an int or a null, and a DateTime or a null and use those instead of Convert methods.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900