C
Chris Divine
Hello,
I sure this is simple, but I cannot see my way through it. I simply want
to add the boolean parameter to the sql string - but can't, as I get the
error message below. Help much appreciated.
MyConnection.Open();
SqlCommand mySqlCommand = new SqlCommand(
"SELECT * FROM Engineer " +
"WHERE STILLEMPLOYED =
@stillemployed");
mySqlCommand.CommandType = CommandType.Text;
mySqlCommand.Parameters.Add(new SqlParameter("@stillemployed",
SqlDbType.Bit));
mySqlCommand.Parameters["@stillemployed"].Value = checkBox11.Checked;
DataSet myDataSet = new DataSet("Engineers");
try
{
(new SqlDataAdapter(mySqlCommand.CommandText,
MyConnection)).Fill(myDataSet, "Engineers");
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show("SQL: " + ex.Message,
"SQL fout");
}
MyConnection.Close();
Error
SQL: Must declare the variable '@stillemployed'.
I sure this is simple, but I cannot see my way through it. I simply want
to add the boolean parameter to the sql string - but can't, as I get the
error message below. Help much appreciated.
MyConnection.Open();
SqlCommand mySqlCommand = new SqlCommand(
"SELECT * FROM Engineer " +
"WHERE STILLEMPLOYED =
@stillemployed");
mySqlCommand.CommandType = CommandType.Text;
mySqlCommand.Parameters.Add(new SqlParameter("@stillemployed",
SqlDbType.Bit));
mySqlCommand.Parameters["@stillemployed"].Value = checkBox11.Checked;
DataSet myDataSet = new DataSet("Engineers");
try
{
(new SqlDataAdapter(mySqlCommand.CommandText,
MyConnection)).Fill(myDataSet, "Engineers");
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show("SQL: " + ex.Message,
"SQL fout");
}
MyConnection.Close();
Error
SQL: Must declare the variable '@stillemployed'.