日期:2014-05-17 浏览次数:20881 次
string sql = string.Format("select * from tt where t1 between '{0}' and '{1}'", dateTimePicker1.Value, dateTimePicker2.Value);
using (SqlConnection conn = new SqlConnection("server=.;database=test;uid=sa;pwd=123456;"))
{
conn.Open();
SqlDataAdapter sda = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
sda.Fill(ds);
this.dataGridView1.DataSource = ds.Tables[0].DefaultView;
}
string sql="select * from tt where t1 between '"+dateTimePicker1.Value+"' and '"+dateTimePicker2.Value+"'"
if(txtgjz.Text!="")
{
sql+=" And 出库单号='"+ txtgjz.Text+"' or 供应商 ='"+ txtgjz.Text+"' ......";
}