虽然该进程正在工作,但我得到了info:Access denied。而这发生在我添加动作来分配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);
}
}
这是 "StoredProcedure"(在Access中他们是查询)。
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";
......通过lable文本分配,它将再次工作。
这意味着Column 0没有映射到一个double。可能应该是GetInt32()或GetDecimal()。
使用调试器找出确切的值和类型。
或者 Debug.Print(reader[0].GetType().Name)
那剩下的就是例外的情况了。我不知道是什么原因。也许这是试图从资源中加载错误信息的后续错误。