此搜索代码是否具有以下任何日期格式?捕捉日期格式“dd-MM-yyyy”。我的桌子是:
id | dat | user | remain
-----------------
1 | 01-03-2013 | x | 1000
----------------
2 | 01-03-2013 | x | 1200
----------------
3 | 02-03-2013 | y | 1100
----------------
4 | 02-03-2013 | y | 1300
----------------
5 | 03-03-2013 | z | 1200
----------------
6 | 03-03-2013 | z | 1400
-------------------------
private void textBox10_Leave(object sender, EventArgs e)
{
if ((textBox10.Text == "yyyy/MM/dd") || (textBox10.Text == "dd/MM/yyyy") || (textBox10.Text == "yyyy-MM-dd"))
{
textBox10.Text = "dd-MM-yyyy";
using (SqlConnection cn = new SqlConnection(Class1.x))
{
cn.Open();
string cm = "select id from item_treasury where dat='" + textBox10.Text + "' order by id";
using (SqlCommand cmd = new SqlCommand(cm, cn))
{
using (SqlDataReader dr = cmd.ExecuteReader())
{
while (dr.Read() == true)
{
if (dr.HasRows == false)
{
MessageBox.Show("xxxxxxxxxxxxxxxxxxxx");
this.Close();
}
comboBox1.Items.Add(dr[0].ToString());
}
}
}
}
}
}
我想更正这段代码。请帮助我!