“/”应用程序中的服务器错误。
参数化查询 '(@adminAccount nvarchar(4000),@adminPwd nvarchar(4000),@adminRol' 需要参数 '@adminAccount',但未提供该参数。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。异常详细信息: System.Data.SqlClient.SqlException: 参数化查询 '(@adminAccount nvarchar(4000),@adminPwd nvarchar(4000),@adminRol' 需要参数 '@adminAccount',但未提供该参数。源错误:
行 110:            SqlCommand cmd = new SqlCommand(sql, connection, transaction);
行 111:            cmd.Parameters.AddRange(values);
行 112:            int result = Convert.ToInt32(cmd.ExecuteScalar());
行 113:            return result;
行 114:        }
源文件: D:\我的文档\Desktop\DuoCai\DuoCaiDLL\DuoCaiDAL\DBHelper.cs    行: 112堆栈跟踪:
[SqlException (0x80131904): 参数化查询 '(@adminAccount nvarchar(4000),@adminPwd nvarchar(4000),@adminRol' 需要参数 '@adminAccount',但未提供该参数。]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +946986
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +821638
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +186
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1932
   System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +31
   System.Data.SqlClient.SqlDataReader.get_MetaData() +62
   System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +297
   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1005
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +32
   System.Data.SqlClient.SqlCommand.ExecuteScalar() +137
   DuoCaiDLL.DuoCaiDAL.DBHelper.GetScalar(String sql, SqlParameter[] values) in D:\我的文档\Desktop\DuoCai\DuoCaiDLL\DuoCaiDAL\DBHelper.cs:112
   DuoCaiDLL.DuoCaiDAL.AdminInfoService.AdminAdd(AdminInfo admin) in D:\我的文档\Desktop\DuoCai\DuoCaiDLL\DuoCaiDAL\AdminInfoService.cs:35
   DuoCaiDLL.DuoCaiBLL.AdminInfoManager.AdminAdd(AdminInfo admin) in D:\我的文档\Desktop\DuoCai\DuoCaiDLL\DuoCaiBLL\AdminInfoManager.cs:33
   DuoCaiApple.DuoCaiBackManageSystem.WebBack.Admin_Add.btnAdd_Click(Object sender, EventArgs e) in D:\我的文档\Desktop\DuoCai\DuoCaiApple\DuoCaiBackManageSystem\WebBack\Admin_Add.aspx.cs:44
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746

解决方案 »

  1.   

    把你@adminAccount相应的那几行代码贴出来,@adminAccount就像是挖了一个坑 需要你去为它填充变量 估计你是没给它填变量 导致的这个问题!
      

  2.   


    +1 检查SQL 查询语句
      

  3.   

    估计@adminAccount它是null导致的
      

  4.   


    using System.Data.SqlClient;
    ......SqlParameter meter;
    SqlCommand cm = new SqlCommand();
    int adminAccount = 0;// 你需要传值的参数,假设当前为0
    meter = new SqlParameter("@adminAccount", adminAccount);
    cm.Parameters.Add(meter);