多条件查询access数据库 - .NET技术 / ASP.NET
页面有5个dropdownlist(ddl1,ddl2,ddl3,ddl4,ddl5)一个TextBox (txt1)
他们可以任意组合去查询数据库
如果其中的莫一个为控制则不参与查询条件中,
能给个代码最好,给个思路也非常的感谢!
string sql=" select * from table where 1=1"
if(ddl1.selectValue!=""){
sql+=" and ddl='"+ddl1.selectValue+"'"
}
if(ddl2.selectValue!=""){
sql+=" and ddl='"+ddl2.selectValue+"'"
}
如此这般
写个拼写sql语句的函数
C# code:
string sqlStr = "select * from table1 where 1=1 "
if (param1.trim() != "")
sqlStr += "and column1='" + param1.trim();
........
StringBuilder sb = new StringBuilder();
sb.Append("select a.kh,a.name,b.fkfs,b.skje,b.czje,b.idate,b.czy from hyxx a,hycz b");
sb.Append(" where a.id=b.hyid ");
sb.Append(" and (a.kh=@kh or @kh is null)");
sb.Append(" and (Convert(char(10),b.idate,120) >= @start or @start is null) ");
sb.Append(" and(Convert(char(10),b.idate,120) <= @endTime or @endTime is null)");
SqlParameter[] para = new SqlParameter[]
相关问答:
1.asp.net做的一个答题页面,如何实时限时后自动提交,请大家给点思路
限时的时间信息存放在数据库中
2.如果答题时间设置的较长,如何方式session超时后页面无效
谢谢
用js方法来控制
回复内容太短了。。
js ......
C# code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Runtime.InteropServices;
nam ......
sqlserver的数据库,字段是image类型的。怎么写代码,在页面中点击“下载”就能打开那个下载对话框?
PS:OracleLob 在sqlserver里是什么?
Response.Redirect("test.jpg")
引用
Response.Redirect( ......
VS2008中C#操作Access数据库,网上下载了一个类,可以正常连接,读取数据,但是插入删除操作似乎有问题,以下是部分代码:
数据库类:
namespace AccessDb
{
public class AccessDbClass
{ ......