0

I am using SQL Server 2005 and Visual Studio 2008. I would like to add a report using an existing dataset. I want to group by Reservation Month BUT the field is dateTime. How can i only display reservvations per month?

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by virusisfound
0
SqlConnection cn = new SqlConnection();
            cn.ConnectionString = "";
            cn.Open();

            SqlDataAdapter da = new SqlDataAdapter("slect * from table name where date=@date", cn);//If you want to display some field of tahe then put the name of taht in the queary.
            da.SelectCommand.Parameters.Add("@date", SqlDbType.NVarChar, 20);
            da.SelectCommand.Parameters["@date"].Value = textBox1.Text.ToString();// spacify the control name from which you are searching the dates. 

            DataSet ds = new DataSet() ;

            da.Fill(ds,"TableName");

            cn.Close();

            CrystalReport1 cr = new  CrystalReport1();

            cr.SetDataSource(ds.Tables[0]);

            //if you have crystal report in another form make crystalreportviwer modifier property to public and the use this
           Form2 fr2 = new Form2();
           fr2.CrystalReportViewer1.ReportSource = cr;
           fr2.CrystalReportViewer1.Refresh();
           fr2.show();

            //otherwise use this
            CrystalReportViewer1.ReportSource = cr;
            CrystalReportViewer1.Refresh();

I hope this will help you.

Edited by virusisfound: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.