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?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.