首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C#依据dateTimePicker1和textbox查询到datagridview

2013-10-31 
C#根据dateTimePicker1和textbox查询到datagridviewC#根据开始时间dateTimePicker1、结束时间dateTimePicke

C#根据dateTimePicker1和textbox查询到datagridview
C#根据开始时间dateTimePicker1、结束时间dateTimePicker2和textbox查询,是查询结果显示到datagridview1
 菜鸟求代码
[解决办法]

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;
            }

[解决办法]
(出库单号 or 供应商 or 录入者 or 审核者 or 记账者 ='"+ txtgjz.Text+"'
这一大段错误了。
出库单号='"+ txtgjz.Text+"' or 供应商 ='"+ txtgjz.Text+"' ......
[解决办法]
string sql="select * from tt where t1 between '"+dateTimePicker1.Value+"' and '"+dateTimePicker2.Value+"'"
 if(txtgjz.Text!="")
{
sql+=" And 出库单号='"+ txtgjz.Text+"' or 供应商 ='"+ txtgjz.Text+"' ......";
}

热点排行