0
我有一个查询将在此情况下返回值和库存类别。如果用户输入某个框号,则表单应该禁用,如果它是表单将启用的其他内容。问题是我使用ExecuteScalar并需要将该值与字符串“AP”进行比较。我对C#很陌生,无法弄清楚如何做到这一点。这里是我的代码到目前为止:将对象与if语句中的变量进行比较c#
private void hide_apple_controls()
{
SqlCommand cmd = new SqlCommand();
Object invCat;
cmd.CommandText = "SELECT itm.inv_cat FROM " +
"t_item_master itm " +
"LEFT OUTER JOIN t_box box (NOLOCK) ON box.product_code LIKE itm.item_number " +
"where box.box_id = @box_id ";
cmd.Parameters.Add("@box_id", SqlDbType.VarChar).Value = boxBox.Text;
cmd.CommandType = CommandType.Text;
cmd.Connection = this.sqlConnection1;
this.sqlConnection1.Open();
SqlDataAdapter adpt = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adpt.Fill(ds);
invCat = cmd.ExecuteScalar();
this.sqlConnection1.Close();
string ap = "AP";
if (invCat == ap)
{
disable_qc_form();
}
enable_qc_form();
}
请标记为答案,如果这解决了您的问题... – Madushan 2012-08-08 08:08:39