Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
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 set = 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(set, "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_Name	Nvarchar(50),
@clrk_Family		Nvarchar(60),
@clrk_MelliCode		Char(10),
@AzTarikh			Date,
@Ela				Date
 
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?
Posted 5-Feb-13 18:52pm
v2
Comments
Sandeep Mewara at 6-Feb-13 1:36am
   
Can you please change your dataset name from keyword 'set' to something else? See if that works.
Elham.Deljooei at 6-Feb-13 1:53am
   
I did your suggest but it doesn't show to me.
Could you tell me What i have to do step by step for report viewer and procedure. I think i don't did it properly?
Rahul Dhoble at 6-Feb-13 2:02am
   
Start the SQL profiler and run this report and see what query you received in profiler.
then run this query manually and see if you get result from sql database.
Elham.Deljooei at 6-Feb-13 2:11am
   
Start the SQL profiler and run this report and see what query you received in profiler.
I don't underestand, what's you mean?
Elham.Deljooei at 7-Feb-13 0:01am
   
Nobody couldn't help me?????????? :=(
I would like to solve this problem.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi everyone
I did it.
 

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();
 
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(dtbl);
//SqlCommand cmd = new SqlCommand("report", con);
//cmd.CommandType = CommandType.StoredProcedure;
//cmd.Parameters.AddWithValue("@clrk_Name", name.Text);
//cmd.Parameters.AddWithValue("@clrk_Family", name.Text);
//cmd.Parameters.AddWithValue("@clrk_MelliCode", name.Text);
//SqlDateTime az_d = SqlDateTime.Parse(az.Text);
//cmd.Parameters.AddWithValue("@AzTarikh", az_d);
//SqlDateTime ela_d = SqlDateTime.Parse(ela.Text);
//cmd.Parameters.AddWithValue("@Ela", ela_d);
//SqlDataAdapter da = new SqlDataAdapter(cmd);
//DataTable dt = new DataTable();
//da.Fill(dt);
 
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();
ReportDataSource source = new ReportDataSource("DataSet1", dtbl);
f1.reportViewer1.LocalReport.DataSources.Add(source);
f1.reportViewer1.LocalReport.Refresh();

f1.Show();

"DataSet1" is name of report's data source. Therefor you can see in Report's smart tag and choose Choose Data Source.
Good luck Friends.
 

}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Nirav Prabtani 304
1 OriginalGriff 237
2 Sergey Alexandrovich Kryukov 196
3 Mika Wendelius 185
4 CPallini 170
0 Nirav Prabtani 284
1 OriginalGriff 217
2 Sergey Alexandrovich Kryukov 196
3 Mika Wendelius 185
4 CPallini 170


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 17 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100