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;
}
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;
}
解决方案 »
- 帮忙写个递归,查询某个目录下所有的文件,以及文件夹,分类显示
- c#查询oracle数据库,绑定变量形式如何做?
- sql语句获取DB2数据库的所有数据库名称
- 请问如何获取网页上鼠标当前指向的URL address
- 在C#里面关于资源释放的问题~~
- c#链表问题
- ascx用户控件能不能放到工具箱里面?
- 。。。grid的DataSource,是一个List<T>。。我在一个方法里面得到DataSource,怎么转成List<T>?
- 怎么让TextArea 不显示HTML代码???? (我只有20分了!!!)
- 请问设置datagrid的每页的记录的条数呢?
- 求助:WPF软件功能页面布局疑惑
- 如何使用DATASET作为存储过程的参数
我这样写,可是有问题,错误时这样的;在应使用条件的上下文(在 'or' 附近)中指定了非布尔类型的表达式.
这一大段错误了。
出库单号='"+ txtgjz.Text+"' or 供应商 ='"+ txtgjz.Text+"' ......
if(txtgjz.Text!="")
{
sql+=" And 出库单号='"+ txtgjz.Text+"' or 供应商 ='"+ txtgjz.Text+"' ......";
}
根据你DropDownList的值 string sql = string.Format("select '{0}' from tt where time between tm1 and tm2",DropDownList.Text)