Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 错误消息";是否由另一个进程使用;?_C# - Fatal编程技术网

C# 错误消息";是否由另一个进程使用;?

C# 错误消息";是否由另一个进程使用;?,c#,C#,虽然该流程正在运行,但我得到了以下信息: 访问被拒绝。当我添加动作来赋值ReaderValue时,就会发生这种情况。没有添加时,一切正常。有什么不对劲吗 private void cb_ReportCategory_SelectedIndexChanged(object sender, EventArgs e) { if(!FirstLoad) { using (OleDbConnection con = new OleDbConnection(Configura

虽然该流程正在运行,但我得到了以下信息: 访问被拒绝。当我添加动作来赋值ReaderValue时,就会发生这种情况。没有添加时,一切正常。有什么不对劲吗

private void cb_ReportCategory_SelectedIndexChanged(object sender, EventArgs e)
{
    if(!FirstLoad)
    {
        using (OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings[2].ToString()))
        {
            using (OleDbCommand com = con.CreateCommand())
            {
                /*com.CommandText = @"SELECT SUM(Amount_Current_quarter) 
                                  FROM qryEmployeeCostsPerRev 
                                  WHERE Bereich=""" + strDepartment + @""" 
                                        AND Vorname_Name=""Unallocated"" 
                                        AND Cost_Cat_Name=""" + cb_ReportCategory.SelectedValue + @"""";*/
                com.CommandText = "sp_EmployeeCostsperRev";
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("Dept", strDepartment);
                com.Parameters.AddWithValue("CostCat", cb_ReportCategory.SelectedValue);

                Debug.Print(com.CommandText);

                con.Open();
                OleDbDataReader reader= com.ExecuteReader();

                if(reader.HasRows)
                {
                    while(reader.Read())
                    {
                        ReaderValue = reader.GetDouble(0);   
                    }
                }
                reader.Close();
                lblAmountValue.Text = Convert.ToString(ReaderValue);

            }

        }
这是“StoredProcess”(在Access中,它们是查询)

。。。通过标签文本分配,它将再次工作

这意味着列0未映射到double。它可能应该是GetInt32()或GetDecimal()

使用调试器找出确切的值和类型

Debug.Print(读取器[0].GetType().Name)


这样一来,例外情况就远远没有了。我不知道是什么原因造成的。这可能是试图从资源中加载errormessage时出现的后续错误

运行此代码时是否关闭Access?您好,是的,当我将循环中的ReaderValue赋值替换为标签文本赋值时,应用程序已关闭,但它将再次工作。但在本例中,它不允许我将读卡器值转换为int或double;选择SUM(资产净值总计每修订金额当前季度)作为t2上的金额(报告成本类别为t1内部联接资产净值根据映射ast t2在t1上。成本类别为t2。报告类别为t2。报告类别为t3内部联接资产净值总计每修订t4在t3上。Kostenstelle=t4。维度成本中心值)。科目编号为t4。科目ID,其中BEREICH=[部门]和Cost_Cat_Name=[CostCat]和Vorname_Name=“未分配”;'现在它不再说对文件的访问被拒绝,但指定的强制转换无效。但是在我再次运行代码之前,我已经将ReaderValue从Double改为decimal或int。是否有任何线程没有显示给我们?Task.Run()?虽然我不太明白问题出在哪里,但它现在正在工作。在debug.print中,我被告知类型是double(如开始定义的那样),在重新转换为double之后,它就工作了。
 PARAMETERS [DEPT] Text ( 10 ), [CostCat] Text ( 20 ); 
 SELECT SUM(NAV_TOTALS_Per_Rev.Amount_current_quarter) AS Amount 
 FROM (ReportCostCategory as t1 INNER JOIN NAV_Acc_Mapping ast t2 
      ON t1.Cost_Cat_Name = t2.Report_Category ) 
      INNER JOIN ([FTE Werte] t3 
          INNER JOIN NAV_TOTALS_Per_Rev t4 ON t3.Kostenstelle = t4.Dimension_CostCenter_Value) 
      ON t2.Account_No = t4.Account_ID 
 WHERE BEREICH=[Dept] AND Cost_Cat_Name=[CostCat] 
                      AND Vorname_Name="Unallocated";