I created a Crystal Report, but I get this error:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in CrystalDecisions.CrystalReports.Engine.dll
Additional information: Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
What I want to do is to get all the data from a table in the database to the report, I created a dataset and create table inside it and I create the Crystal Report.
My code:
private void btn_test_Click(object sender, EventArgs e)
{
connection = new SqlConnection(connectionString1);
connection.Open();
SqlDataAdapter adapter = new SqlDataAdapter("CRP_daily", connection);
adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
DataSet DATACR = new DataSet();
adapter.Fill(DATACR);
connection.Close();
CrystalReport.Report RE = new CrystalReport.Report();
RE.Database.Tables["daily"].SetDataSource(DATACR);
CRV_Daily.ReportSource = null;
CRV_Daily.ReportSource = RE;
}
daily
is the table in the dataset .
CRP_daily
is my stored procedure in SQL Server:
CREATE PROCEDURE CRP_daily
AS
BEGIN
SELPECT
Cashier_ID, CustomerNo, OrderName, Quantity, Price, Serves_way, Discount, Date
FROM
Tbl_TemporaryOrderPrint;
END
What is wrong with my code ? I can't get it....
Sorry I'm just new doing the Crystal Report
User contributions licensed under CC BY-SA 3.0