Sunday, 18 August 2013

Cannot implicity convert type 'string' to 'bool'

Cannot implicity convert type 'string' to 'bool'

I'm having an error when I run my project. I want to create an if
statement if the textbox1 is empty.My code is like this:
SqlCommand cmd = new SqlCommand(" DELETE from Records WHERE
([Student ID]='" + textBox1.Text + "')", con);
MessageBox.Show("Data Deleted!", "Information ... ",
MessageBoxButtons.OK, MessageBoxIcon.Information,
MessageBoxDefaultButton.Button1);
textBox1.Text = " ";
if (textBox1.Text = " ")
{
MessageBox.Show("Please enter Student ID", "Delete
Failed",MessageBoxButtons.OK,MessageBoxIcon.Error,MessageBoxDefaultButton.Button1);
}
cmd.ExecuteNonQuery();
con.Close();
The error is on texbox1.Text = " "

No comments:

Post a Comment