string a="";
SqlCommand mycom=new SqlCommand (a,sqlCon );
mycom.CommandText = "Select count (*) recordcount from Holidaysadjustement where Date = '" + dateTimePickertxtTJJBSH.Value + "'";
if (Convert.ToInt32(mycom.ExecuteScalar ()) >0)
{
MessageBox.Show("请输入时间!");
}
dateTimePickertxtTJJBSH是我的一个时间控件,Holidaysadjustement表的名字,Date表中字段的名字
我要实现的是判断我输入的控件里的时间是否等于表Holidaysadjustement中Date字段中的某个值,如果等于,则提示MessageBox.Show("请输入时间!");
现在当我把控件的值附成和数据表字段的某个值相同的时候,比如说数据表有2011-01-01 然后我把控件的值也附成这个,但是没有那个提示。请各位高手帮我改改代码,谢谢啦!憋了一天了 ,实在不会。
Select count (*) recordcount from Holidaysadjustement where Date = '" + dateTimePickertxtTJJBSH.Value + "'
我要是把'" + dateTimePickertxtTJJBSH.Value + "'换成'2011-1-1',在数据库中执行,是有返回结果的。
SqlCommand mycom=new SqlCommand (a,sqlCon );
mycom.CommandText = "Select count (*) recordcount from Holidaysadjustement where Date = '" + dateTimePickertxtTJJBSH.Value + "'";
if (Convert.ToInt32(mycom.ExecuteScalar ()) >0)
{
MessageBox.Show("请输入时间!");
}
dateTimePickertxtTJJBSH是我的一个时间控件,Holidaysadjustement表的名字,Date表中字段的名字
我要实现的是判断我输入的控件里的时间是否等于表Holidaysadjustement中Date字段中的某个值,如果等于,则提示MessageBox.Show("请输入时间!");
现在当我把控件的值附成和数据表字段的某个值相同的时候,比如说数据表有2011-01-01 然后我把控件的值也附成这个,但是没有那个提示。请各位高手帮我改改代码,谢谢啦!憋了一天了 ,实在不会。
Select count (*) recordcount from Holidaysadjustement where Date = '" + dateTimePickertxtTJJBSH.Value + "'
我要是把'" + dateTimePickertxtTJJBSH.Value + "'换成'2011-1-1',在数据库中执行,是有返回结果的。
if (Convert.ToInt32(mycom.ExecuteScalar ()) >0)看下mycom.CommandText的值是多少在说