|
sajitha
Starting Member
Australia
8 Posts |
Posted - 12/13/2012 : 22:10:21
|
If I click any of the tools in Crystal Report viewer it shows " The report you requested requires further information" message.Help will be appreciated.Find my code below
Thank You in advance. **************************************************************** <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" DisplayToolbar="true" /> **************************************************************** protected void btnreport_Click(object sender, EventArgs e) { ReportDocument rptDoc = new ReportDocument(); AttendanceDataSet ds = new AttendanceDataSet(); // .xsd file name DataTable dt = new DataTable(); TableLogOnInfo myLogOnInfo = new TableLogOnInfo(); CrystalReportViewer1.LogOnInfo = new TableLogOnInfos(); myLogOnInfo.ConnectionInfo.ServerName = "SARJ-PC\\SQLSERVER"; myLogOnInfo.ConnectionInfo.DatabaseName = "TMS"; myLogOnInfo.ConnectionInfo.UserID = "kuts"; myLogOnInfo.ConnectionInfo.Password = "password1234";
// Just set the name of data table dt.TableName = "Crystal Report Example"; dt = getAllOrders(); //This function is located below this function ds.Tables[0].Merge(dt);
// Your .rpt file path will be below //rptDoc.Load(Server.MapPath("StudentCrystalReport.rpt")); rptDoc.Load(Request.PhysicalApplicationPath + "StudentCrystalReport.rpt"); //set dataset to the report viewer. rptDoc.SetDataSource(ds); CrystalReportViewer1.EnableDatabaseLogonPrompt = true;
CrystalReportViewer1.ReportSource = rptDoc; CrystalReportViewer1.DataBind();
}
public DataTable getAllOrders() { //Connection string replace 'databaseservername' with your db server name //string dt1 = fromDateTextBox.Text; //string dt2 = toDateTextBox.Text; string sqlCon = "Server=SARJ-PC\\SQLSERVER;" + "Database=TMS;User ID=kuts; Password=password1234"; SqlConnection Con = new SqlConnection(sqlCon); SqlCommand cmd = new SqlCommand(); DataSet ds = null; SqlDataAdapter adapter; try { Con.Open(); //Stored procedure calling. It is already in sample db. cmd.CommandText = "getAllOrders"; //cmd = new SqlCommand("select Activity.ActID, Activity.User_id, Activity.Trainer_Name, Activity.Hours, Activity.Date, Activity.Subject, Login_log.Login_time, Login_log.Logout_time, Login_log.Clock_in, Login_log.Clock_out from Activity, Login_log where Activity.User_id =@uid and Login_log.Login_time >= @fromDate and Login_log.Logout_time <=@toDate and Activity.User_id = Login_log.User_id and Activity.ActID = Login_log.ActID ", Con); cmd = new SqlCommand("SELECT dbo.Login.Login_name, dbo.Activity.ActID, dbo.Activity.User_id, dbo.Activity.Trainer_Name, dbo.Activity.Student_Name, dbo.Activity.Project_Name, dbo.Activity.Hours, dbo.Task.Task_Name, dbo.Login_log.Login_time, dbo.Login_log.Logout_time, dbo.Login_log.Clock_in, dbo.Login_log.Clock_out FROM dbo.Login, dbo.Activity INNER JOIN dbo.Login_log ON dbo.Activity.logID = dbo.Login_log.logID INNER JOIN dbo.Task ON dbo.Activity.TaskID = dbo.Task.TaskID where dbo.Login.User_id = @uid and dbo.Activity.User_id = @uid and dbo.Activity.Date between convert(datetime, @fromDate ,5) and convert(datetime, @toDate, 5) ", Con); cmd.Parameters.Add("@uid", System.Data.SqlDbType.Int); cmd.Parameters["@uid"].Value = userIDTextBox.Text; cmd.Parameters.Add("@fromDate", System.Data.SqlDbType.DateTime); cmd.Parameters["@fromDate"].Value = Convert.ToDateTime(fromDateTextBox.Text); cmd.Parameters.Add("@toDate", System.Data.SqlDbType.DateTime); cmd.Parameters["@toDate"].Value = Convert.ToDateTime(toDateTextBox.Text);
cmd.Connection = Con; ds = new DataSet(); adapter = new SqlDataAdapter(cmd); adapter.Fill(ds, "Users"); } catch { errorLabel.Text = "Ooops Error!!!"; } finally { cmd.Dispose(); if (Con.State != ConnectionState.Closed) Con.Close(); } return ds.Tables[0]; }
} |
|