SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Analysis Server and Reporting Services (2008)
 Issue in displaying Crystal Report
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sajitha
Starting Member

Australia
10 Posts

Posted - 12/13/2012 :  22:10:21  Show Profile  Reply with Quote
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];
}


}

sz1
Constraint Violating Yak Guru

United Kingdom
457 Posts

Posted - 12/19/2012 :  10:43:09  Show Profile  Reply with Quote
Did you write the report or is this an old/existing report you are trying to run?

This text would suggest you are using an old db connection and you need to setup the db connection to the current db. That also means that the fields will be out of date if the db are not the same.

Connection string replace 'databaseservername' with your db server name
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000