运行项目时出现错误。如果 textbox1 为空,我想创建一个 if 语句。我的代码是这样的:
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();
错误出现在 texbox1.Text = " "