本文介绍了dateTimePicker1_ValueChanged的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

invoice_date>>>>键入列日期时间









private void dateTimePicker1_ValueChanged_1(object sender, EventArgs e)

{

SqlDataAdapter sda = new SqlDataAdapter(select ic.fk_id_product,

ic.name_product,ic.price,ih。 invoice_date,ih.fk_id_store来自TBL_InvoicContent as ic

内部联接TBL_InvoiceHead as ih on ih.invoice_id = ic.id_invoice

其中ih.invoice_date喜欢'%'+ dateTimePicker1.Text .ToString()+%',sqlcon);





DataTable dt2 = new DataTable();

sda.Fill(dt2);

dataGridView1.DataSource = dt2;

}



this select语句不起作用

invoice_date>>>> Type column datetime




private void dateTimePicker1_ValueChanged_1(object sender, EventArgs e)
{
SqlDataAdapter sda = new SqlDataAdapter("select ic.fk_id_product ,
ic.name_product ,ic.price ,ih.invoice_date , ih.fk_id_store from TBL_InvoicContent as ic
inner join TBL_InvoiceHead as ih on ih.invoice_id = ic.id_invoice
where ih.invoice_date like '%" + dateTimePicker1.Text.ToString() + "%' ", sqlcon);


DataTable dt2 = new DataTable();
sda.Fill(dt2);
dataGridView1.DataSource = dt2;
}

this select statement not working

推荐答案

SqlDataAdapter sda = new SqlDataAdapter(String.Format("select ic.fk_id_product ,
ic.name_product ,ic.price ,ih.invoice_date , ih.fk_id_store from TBL_InvoicContent as ic
inner join TBL_InvoiceHead as ih on ih.invoice_id = ic.id_invoice
where CONVERT(VARCHAR,ih.invoice_date,120) like '{0}'",dateTimePicker1.Text.ToString()), sqlcon);



请注意CONVERT的最后一个参数:它是使用区域设置时需要考虑的格式标识符。请参阅:]


这篇关于dateTimePicker1_ValueChanged的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 11:41