zoukankan      html  css  js  c++  java
  • MSSQLSERVER数据库 C#里调用存储过程,多参数查询,个人记录

      这是我第一次使用存储过程,进行表合并后这么多参数的查询。

      记录一下大概的例子,以便下次查阅

                StringBuilder sb = new StringBuilder();
    
                sb.AppendFormat(" BankID='{0}' ", ddlBank.SelectedValue);
    
                if (txtCheckDateStart.Value != "" && txtCheckDateEnd.Value != "")
                {
                    sb.AppendFormat(" And CheckDate Between '{0}' And '{1}' ", txtCheckDateStart.Value, txtCheckDateEnd.Value);
                }
    
                if (txtImportDateEnd.Value != "" && txtImportDateStart.Value != "")
                {
                    sb.AppendFormat(" And ImportDate Between '{0}' And '{1}' ", txtImportDateStart.Value, txtImportDateEnd.Value);
                }
    
                if (txtUserName.Text != "")
                {
                    sb.AppendFormat(" And LoginName='{0}' ", txtUserName.Text);
                }
    
                if (txtCheckInAmount.Text != "")
                {
                    sb.AppendFormat(" And CheckInAmount='{0}' ", txtCheckInAmount.Text);
                }
                Response.Write(sb.ToString());
                //GridView1.DataSource = DbHelperSQL.GetSplitPageList("BankDataImport", "*", "ID", "DESC", 12, 1, "");
                //GridView1.DataSource = DbHelperSQL.GetSplitPageList(@"BankDataImport b inner join Users u on b.UserId = u.Id",
                //        "b.ID, b.UserID, b.ImportDate, b.CheckDate, b.CheckOutAmount, b.CheckInAmount, b.BankID, b.Remark, b.UCheckInAmount, b.DeptID,u.LoginName","b.Id","DESC",20,1,"");
    
                GridView1.DataSource = DbHelperSQL.GetSplitPageList("BankDataImport b inner join Users u on b.UserId = u.Id", "b.ID,b.UserID,b.ImportDate,b.CheckDate,b.CheckOutAmount,b.CheckInAmount,b.BankID,b.Remark,b.UCheckInAmount,b.DeptID,u.LoginName", "b.ID", "DESC", 12, 1, sb.ToString());
  • 相关阅读:
    求职简历撰写要点和模板分享
    find命令
    MD5Init-MD5Update-MD5Final
    Linux find命令详解
    Linux进程KILL不掉的原因
    Linux操作系统的内存使用方法详细解析
    Lsof命令详解
    为什么ps中CPU占用率会有超出%100的现象?
    第12课 经典问题解析一
    第11课 新型的类型转换
  • 原文地址:https://www.cnblogs.com/cxeye/p/2959571.html
Copyright © 2011-2022 走看看