Say I need to satisfy if else statement that
- CustomerCode must be filled in(not null)
- CustomerCode must be dataType varchar
How to write if else correctly?
Thanks for any help in advanced, guys!
sqlCustomerMaster.InsertParameters["CustomerCode"].DefaultValue =
txtCustomerCode.Text.ToString();
try
{
txtCustomerCode.Text = "";
if (txtCustomerCode.Text != null)
{
sqlCustomerMaster.Insert();
}
else
{
}
}
Since the input is from a text box there always should be a mapping to
varchar, so you just want to check whether the string is null or empty:This will guarantee
txtCustomerCode.Texthas at least one character but not whether its numeric etc, but you did not list any other conditions.