If statement to validate optional fields

If statement to validate optional fields

i am trying to write a code to retrieve user record from a database and then
send an email to that user showing him his data(record)

but i have a condition.. i want to write an if statement that checks the retrived
data from the database for a spesific user..let say i want to check the phone number..
if it contain a number write it in the email.. if not or is it Null
don't write it in the email...

so, any idea how to do this?check in first if statement
use isDigit property for variable in which phone no. is strored

and in body of if
u can write it in mail.
as u using Mailobject class's object obj.
obj.Body=convert.Tostring(phone_number)+"\n"+body
//where body is the source of mail body

segment of code is not synttically correct..........You can use the IsDbNull method with either a datarow item or a datareader item.


'Dr is assumed to be a datarow from your datatable.
If IsDbNull(Dr.Item("PhoneNumber")) = False Then
'Write stuff to email string
End If
 
Back
Top