[英]System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation
i am using entity framework and storage process and crystal report我正在使用实体框架和存储过程以及水晶报告
i wanna get storage process and view it in crystal report我想获取存储过程并在水晶报告中查看它
but i get this error但我收到这个错误
System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.'
inner exception
NullReferenceException: Object reference not set to an instance of an object.
This exception was originally thrown at this call stack:
CrystalDecisions.CrystalReports.Engine.Table.Fields.get()
this is storage process这是存储过程
USE [PayRoll]
GO
/****** Object: StoredProcedure [dbo].[SR1] Script Date: 12/09/2020 15:41:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Procedure [dbo].[SR1]
As
BEGIN
SELECT
EmployeeCode,EmployeeName,JopName,Date_Hiring,Nat_Salary
FROM
Employee_List_Code_Name_Jop_DateHiring
END
and this is Code to call storage process error show here rpt.SetDataSource(bs);这是调用存储过程错误的代码 rpt.SetDataSource(bs);
if(Report_Number == "2")
{
var Employee_Data = db.Database.SqlQuery<Table>("EXEC SR1").ToList();
bs.DataSource = Employee_Data;
}
//
//
//
ReportDocument rpt = new ReportDocument();
rpt.Load(Application.StartupPath + "\\Report\\Arabic\\" + "R" + Report_Number + ".rpt");
rpt.SetDataSource(bs);
and this storage process class和这个存储过程类
namespace PayRoll.database
{
using System;
public partial class SR1_Result
{
public int EmployeeCode { get; set; }
public string EmployeeName { get; set; }
public string JopName { get; set; }
public System.DateTime Date_Hiring { get; set; }
public double Nat_Salary { get; set; }
}
}
how can fixed this error??如何修复此错误?
i get error in sql query我在 sql 查询中出错
replace代替
SqlQuery查询
SqlQuery<SR1_Result> SqlQuery<SR1_Result>
like this像这样
if(Report_Number == "2")
{
var Employee_Data = db.Database.SqlQuery<SR1_Result>("SR1").ToList();
bs.DataSource = Employee_Data;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.