i want to know how to give if condition with database connectivity. i have code like this
private void button1_Click(object sender, EventArgs e)
{
{
SqlConnection con = new SqlConnection(@"server=CSE-PC; integrated security=true; Database=Bas");
con.Open();
SqlCommand cmd1 = new SqlCommand("insert into devi Values('" + comboBox1.Text + "',+'" + comboBox2
.Text + "','" + comboBox3.Text + "','" + comboBox4.Text + "','" + comboBox5.Text + "','" + comboBox6.Text + "','" + comboBox7.Text + "')", con);
cmd1.ExecuteNonQuery(); hera, i need to give if condition for null. i.e . if box is empty it does not store. it need to show message as MessageBox.Show("doesnot store null value");
con.Close();
MessageBox.Show("Added Successfully");
comboBox1.Text = "";
comboBox2.Text = "";
comboBox3.Text = "";
comboBox4.Text = "";
comboBox5.Text = "";
comboBox6.Text = "";
comboBox7.Text = "";
}
}
how give if condition for this please help me
how give if condition for this please help me

Khargesh RajputPosted Mar 23, 2015, 5:30 AM
{
messagebox.show("Should not null");
}
else
{
Insert Values into your D/B
}
Durga VelusamyPosted Mar 23, 2015, 8:03 AM
Raja TPosted Mar 23, 2015, 6:11 AM
private void button1_Click(object sender, EventArgs e)
{
if (comboBox2.Text == "" || comboBox3.Text == "" || comboBox4.Text == "")
{
MessageBox.Show("doesnot store null value");
return;
}
MessageBox.Show("Added Successfully");
}
Please refere this
Thanks