当前位置:Gxlcms > 数据库问题 > SQL查询操作

SQL查询操作

时间:2021-07-01 10:21:17 帮助过:36人阅读

DataTable GetData(string cboCld, string cboFact,string cboPrtN,string txtbCde,string txtbDce,string txtbPdt,string txtbRID) { string strSql = @"select distinct l.Area,l.Facility ,m.vdpartno,l.PartNo,l.ReelID,l.Qty ,l.Location,l.datecd,l.prodcd,l.vendorcd,l.lmdate from VMIReelShelfDetail l left JOIN smtitem m ON m.partno = l.partno where l.ReelID <>‘‘"; if (cboCld != "ALL") { strSql = strSql + " AND l.Area=‘" + cboCld + ""; } if (cboFact != "ALL") { strSql = strSql + " AND l.Facility=‘" + cboFact + ""; } if (cboPrtN != "ALL") { strSql = strSql + " AND l.PartNo=‘" + cboPrtN + ""; } if (txtbCde != "") { strSql = strSql + " AND l.vendorcd=‘" + txtbCde + ""; } if (txtbDce != "") { strSql = strSql + " AND l.datecd=‘" + txtbDce + ""; } if (txtbPdt != "") { strSql = strSql + " AND l.prodcd=‘" + txtbPdt + ""; } if (txtbRID != "") { strSql = strSql + " AND l.ReelID=‘" + txtbRID + ""; } return SqlHelper.Query(strSql); }

 

通过判断这几个界面上的文本框和复选框,来追加SQL中的查询条件最为方便 且简单。

SQL查询操作

标签:HERE   lin   linq查询   smt   distinct   public   mda   tail   date   

人气教程排行