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);
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
replace
SqlQuery
SqlQuery<SR1_Result>
like this
if(Report_Number == "2")
{
var Employee_Data = db.Database.SqlQuery<SR1_Result>("SR1").ToList();
bs.DataSource = Employee_Data;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.