string sql1 = null,sql = null;
string out1 = outdate1ValueToShortDateString();
if (out1 != "") sql1 = " 出库日期>='" + out1 + "'";
string out2 = outdate2ValueToShortDateString();
if (out2 != "") sql1 += " AND 出库日期<='" + out2 + "'";
string return1 = returndate1ValueToShortDateString();
if (return1 != "") sql1 += " AND 归还日期>='" + return1 + "'";
string return2 = returndate2ValueToShortDateString();
if (return2 != "") sql1 += " AND 归还日期<='" + return2 + "'";
string type = combobox1TextToString();
if(type !=""){sql1 += " AND 类别 = '" + type + "'";}
string status = combobox2TextToString();
if(status !=""){sql1 += " AND 状态 = '" + status + "'";}
string ways = textboxTextToString();
if(ways != ""){sql1 += " AND 方式 = '" + ways + "'";}
sql = "select from 表名 where" +sql1;
刚写的,没测试过。
以上就是关于c#多条件查询数据库代码如何编写,很急!全部的内容,包括:c#多条件查询数据库代码如何编写,很急!、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)