elham deljooei

elham deljooei

  • NA
  • 84
  • 73.2k

report viewer and stored procedure

Feb 6 2013 2:38 AM
Hi friends.
I want to show my report in report viewer but it dosen't show for me.
This my code:
   private void buttonX1_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection("Data Source=FADAEILAPTOP-PC;Initial Catalog=ClerksEvaluation;Integrated Security=True");

            DataSet a = new DataSet();
            DataTable dtbl = new DataTable("DataTable1");

            SqlDataAdapter adp = new SqlDataAdapter();
            adp.SelectCommand = new SqlCommand();
            adp.SelectCommand.Connection = con;

            adp.SelectCommand.CommandText = "Report";
            adp.SelectCommand.CommandType = CommandType.StoredProcedure;

            adp.SelectCommand.Parameters.AddWithValue("@clrk_Name", name.Text);
            adp.SelectCommand.Parameters.AddWithValue("@clrk_Family", family.Text);
            adp.SelectCommand.Parameters.AddWithValue("@clrk_MelliCode", melli.Text);
            SqlDateTime az_d = SqlDateTime.Parse(az.Text);
            adp.SelectCommand.Parameters.AddWithValue("@AzTarikh", az_d);
            SqlDateTime ela_d = SqlDateTime.Parse(ela.Text);
            adp.SelectCommand.Parameters.AddWithValue("@Ela", ela_d);
            adp.Fill(a, "DataTable1");

            Form1 f1 = new Form1();


            ReportDataSource source = new ReportDataSource("datatable1", dtbl);
            f1.reportViewer1.Visible = true;
            f1.reportViewer1.ProcessingMode = ProcessingMode.Local;
            f1.reportViewer1.LocalReport.ReportPath = "Report1.rdlc";
            f1.reportViewer1.LocalReport.DataSources.Clear();
            f1.reportViewer1.LocalReport.DataSources.Add(source);

            f1.reportViewer1.LocalReport.Refresh();
            f1.Show();
        }
this doesn't have any error.
this is my procedure and it doesn't have error.
USE [ClerksEvaluation]
GO
/****** Object:  StoredProcedure [dbo].[Report]    Script Date: 02/06/2013 09:17:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[Report]

@clrk_NameNvarchar(50),
@clrk_FamilyNvarchar(60),
@clrk_MelliCodeChar(10),
@AzTarikhDate,
@ElaDate

AS

Declare @id int
select @id = clrk_Id from Clerk 
where clrk_Name = @clrk_Name and clrk_Family = @clrk_Family and clrk_MelliCode = @clrk_MelliCode

select  clrk_Name,clrk_Family,clrk_MelliCode,clrk_FatherName, epcnt_Name, clrke_Percent, clrke_Tozihat, clrke_Date, clrke_Hafteh  
from ClerkEvaluation
inner join Clerk on Clerk.clrk_Id = @id
inner join EvaluationPercent on ClerkEvaluation.epcnt_Id = EvaluationPercent.epcnt_Id
where clrke_Date Between @AzTarikh and @Ela
my ReportViewer binded to procedure.
Could you help me?
 

Answers (7)