Click here to Skip to main content
14,934,026 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i have using this code for print a specify row value in RDLC
SQL database:
create database test
create table fst(ename varchar(50),ecity varchar(50),ephno varchar(50))

button click coding:
C#
con.Open();
           string query = "select*from fst where ename='" + textBox1.Text + "'";
           SqlCommand cmd = new SqlCommand(query, con);
           this.reportViewer1.LocalReport.ReportEmbeddedResource = "WindowsFormsApplication3.Report1.rdlc";
           ReportParameter[] para = new ReportParameter[3];
           SqlDataReader dr = null;
           dr = cmd.ExecuteReader();
           if (dr.Read())
           {
               para[0] = new ReportParameter("ename", dr["ename"].ToString());
               para[1] = new ReportParameter("ecity", dr["ecity"].ToString());
               para[2] = new ReportParameter("ephno", dr["ephno"].ToString());
               this.reportViewer1.LocalReport.EnableExternalImages = true;
               this.reportViewer1.LocalReport.SetParameters(para);
               this.reportViewer1.AutoScroll = true;
               this.reportViewer1.AutoSize = true;
               this.reportViewer1.RefreshReport();
           }
           con.Close();

Store Procedure coding:
SQL
create PROCEDURE demo (	@ename varchar(50),@ecity varchar(50),@ephno varchar(50))
AS insert into fst values(@ename,@ecity,@ephno)

in my some old project that coding work but now it show the error. please help. when i add SP paremeter in report textbox it show erroe is:
The Value expression for the text box ‘Textbox1’ refers to a non-existing report parameter ‘ename’
Posted
Updated 8-Sep-15 19:51pm
v3

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




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900