I am using crystal reports as follows.i m passing three parameters fromdate,todate and userid to my query for loading crystal report.the crystal report loads properly and the query also brings the records properly.I m binding report from code behind as follows.
on page load and GenerateReport button click :-
ReportDocument rptDoc = new ReportDocument();
dsSample ds = new dsSample(); //.xsd file name
DataTable dt = new DataTable();
// Just set the name of data table
dt.TableName = "Crystal Report";
dt = getAllData(); //This function is located below this function
ds.Tables[0].Merge(dt);
// Your .rpt file path will be below
rptDoc.Load(Server.MapPath("CReport2.rpt"));
//set dataset to the report viewer.
rptDoc.SetDataSource(ds);
CrystalReportViewer1.ReportSource = rptDoc;
CrystalReportViewer1.RefreshReport();
Getalldata function contains the query as
private DataTable getAllData()
{
//int Uid = Convert.ToInt32(ddlUser.SelectedValue);
//txtFrom.Text =
//txtTo.Text = Session["FrmDateRpt"].ToString();//currentdate can also be used
//ddlUser.SelectedValue = Session["UsrRpt"].ToString();
DataSet ds = null;
try
{
// Open Sql Connection
string connstr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString.ToString();
SqlConnection SqlCon = new SqlConnection(connstr);
SqlCon.Open();
// Create a Command
SqlCommand SqlComm = new SqlCommand();
SqlComm.Connection = SqlCon;
SqlComm.CommandType = CommandType.Text;
string query = "SELECT first_name,last_name,country,Quantity FROM Table1 where convert(datetime,FromDate,101) >='" + txtFrom.Text + "' and convert(datetime,ToDate,101) <='" + txtTo.Text + "' and userid =" + ddlUser.SelectedValue + "" ;
SqlComm.CommandText = query;
ds = new DataSet();
SqlDataAdapter SqlDa = new SqlDataAdapter(SqlComm);
SqlDa.Fill(ds, "DataTable1");
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
}
return ds.Tables[0];
}
Report shows me some records on first page but when i click on next page button to see more records it dispalys no records.Whats the problem i m not able to understand.Help Me..