vineet pathak

vineet pathak

  • NA
  • 254
  • 0

Crystal reports

May 28 2010 1:09 AM
Hi everyone,

I have created crystal reports recently.I have modified the application using two textboxes and button outside the crystal report viewer.If I enter any name in first checkbox and second name in another and click on search button,then the data between the entered names should be displayed in my report viewer.I have used stored procedure as follows:

//stored procedure//

ALTER PROCEDURE spSearch1
(
@Search1 varchar(50),
@Search2 varchar(50)
)
AS
BEGIN

SET NOCOUNT ON;

SELECT *
FROM cr2 Where FirstName = @search1 and LastName=@search2

END

//on search button click//

SqlConnection con=new SqlConnection("Data Source=server;Initial Catalog=CR;User ID=uttam;Password=uttam");
con.Open();
SqlCommand cmd=new SqlCommand("spSearch1",con );
DataSet ds=new DataSet();
SqlDataAdapter da=new SqlDataAdapter();
da.SelectCommand=cmd;
cmd.Parameters.Add("@search1", SqlDbType.VarChar).Value = TextBox1 .Text;
cmd.Parameters.Add("@search2", SqlDbType.VarChar).Value = TextBox2 .Text;


cmd.CommandType = CommandType.StoredProcedure;
da.Fill(ds);
cmd.ExecuteReader();
con.Close();

Please help me out of it.I am sticked to this problem from the past two days.Kindly send me the code,so that on serarch button the report should show the values between the entered values in textboxes.

Urgently reply,
Vineet


Answers (1)