这里是我的代码..................
但我得到的错误= char数据类型到smalldatetime数据类型的转换导致在一个范围的smalldatetime值。private void dateTimePicker1_Leave(object sender, EventArgs e)
{
SqlConnection con = Conn.getopenedconnection();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
DateTime date1 = Convert .ToDateTime(dateTimePicker1.Text) ;
string date11 = date1.ToShortDateString();
cmd.CommandText = ("SELECT itemcode,maturity FROM SAUDAMAST WHERE COMPCODE='" + Compcls.Gcomp_cd + "'and itemcode='"+comboBox1.SelectedValue+"' and maturity='"+date11+"'");
SqlDataReader sdr = cmd.ExecuteReader();
int count = 0;
while (sdr.Read())
{
count = 1;
}
if (count > 0)
{
MessageBox.Show("Sauda already exists this comodity and this date");
dateTimePicker1.Focus();
}
}
请帮助我,我必须做的......
感谢和问候
拉坎