Hello everyone,I have been working with the reports. but the problem lies when the reports are being displayed. IT IS PROMTING FOR THE PASSWORD EVERY TIME I DISPLAY THE REPORTS.Can you tell me how to avoid this.
Its very urgent. Please find time for me.
thanks in advance.
|
Go4Expert Founder
|
![]() |
| 25Sep2006,10:35 | #2 |
|
Can you clarify your problem a bit more as I could not get you?
|
|
Newbie Member
|
|
| 26Sep2006,10:30 | #3 |
|
Whenever my report run its displayes a window in which it asking abt User, Password of the database Sqlserver 2000. i dont want to do this at run time i req whenever i run my report it directly shows the record not asking me abt Login n password of the database. for this i used the following coding in the page load but nothing happens it gaves error
"" invalid report file path "", here is the code:: Code:
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
public partial class _Default : System.Web.UI.Page
{
ReportDocument rd = new ReportDocument();
protected void Page_Load(object sender, EventArgs e)
{
rd.SetDatabaseLogon("saima", "allah", "VSDC", "DANCOM");
string reportpath = Server.MapPath("CrystalReport.rpt");
}
}
Last edited by shabbir; 26Sep2006 at 10:41.. Reason: Code formating. |
|
Go4Expert Founder
|
![]() |
| 26Sep2006,10:42 | #4 |
|
There is an option in the menu where you can have the option of Save Password so that it does not ask each time. I dont have the CR installed on my pc right now so could not tell you the exact menu location.
|
|
Newbie Member
|
|
| 26Sep2006,11:02 | #5 |
|
i m using CR 10 and i didn't find any option for this anyways thanx . Let me check again
|
|
Newbie Member
|
|
| 30Jan2007,08:31 | #6 |
|
In my opinion, working with DataAdapters and DataSets is more flexible and more accurate.
Anyway, I don't really know your way of doing, but with a proper connectionString it works fine for my needs. Here is an instance: Code:
string conStr = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=UserPassword";
SqlConnection con;
SqlDataAdapter da;
ReportDocument rd;
DataSet ds;
try
{
ds = new DataSet();
con = new SqlConnection(conStr);
rd = new ReportDocument();
string sql = "SELECT * FROM TABLE";
da = new SqlDataAdapter(sql, con);
da.Fill(ds, "DataTableName");
rd.SetDataSource(ds);
}
catch(Exception ex)
{
throw new Exception("Internal error: " +ex.Message);
}
finally
{
rd.Close();
if(ds != null) ds.Dispose();
if(da != null) da.Dispose();
}
Hope this helps. Last edited by shabbir; 30Jan2007 at 14:22.. Reason: Code formating. |
|
Go4Expert Founder
|
![]() |
| 30Jan2007,14:23 | #7 |
|
GIC, welcome to the forums and I have edited your post to include the code into the code block so that its easier to read.
|
|
Newbie Member
|
|
| 30Jan2007,20:38 | #8 |
|
Thank you Shabbir,
How do I put the code within a code block, as you call it, so that the posted code may be easier to read ? |
|
Go4Expert Founder
|
![]() |
| 30Jan2007,20:46 | #9 |
|
Here is the link Before you make a query.
Quote:
|
|
Newbie Member
|
|
| 31Jan2007,00:28 | #10 |
|
I have a little problem when trying to create my report dynamically.
First, let's say that my report contains two subreport sections. Then, I try to make it available to my Windows Application, but I get this error at runtime: "Unable to find the report in the manifest resources." Here is how I load my report. Code:
ReportDocument rd = new ReportDocument();
SqlConnection con = new SqlConnection(properlyDefinedConnectionString);
SqlDataAdapter da;
DataSet ds1;
DataSet ds2;
DataSet ds3;
rd.Load(this.reportPath + this.reportName);
try
{
ds1 = new Dataset();
string cmdTxt = "SELECT * FROM Table1";
da = new SqlDataAdapter(cmdTxt, con);
// Table1View being the name of the datasource within the report.
da.Fill(ds1, "Table1View");
rd.SetDataSource(ds);
cmdTxt = "SELECT * FROM Table2";
da.Dispose();
da = new SqlDataAdapter(cmdTxt, con);
da.Fill(ds2, "Table2View");
cmdTxt = "SELECT * FROM Table3";
da.Dispose();
da = new SqlDataAdapter(cmdTxt, con);
da.Fill(ds3, "Table3View");
foreach(Section s in rd.ReportDefinition.Sections)
foreach(ReportObject ro in s.ReportObjects)
if(ro.Kind == ReportObjectKind.SubreportObject)
{
ReportDocument srd = new ReportDocument();
SubreportObject srdObj = (SubreportObject)ro;
switch(srdObj.OpenSubreport(srdObj.SubreportName).Name)
{
case "Table2View":
{
srdObj.SetDataSource(ds2);
break;
}
case "Table3View":
{
srdObj.SetDataSource(ds3);
break;
}
}
}
}
catch(Exception ex)
{
throw new Exception("Internal Error: " + ex.Message);
}
finally
{
rd.Close();
if(ds1 != null) ds1.Dispose();
if(ds2 != null) ds2.Dispose();
if(ds3 != null) ds3.Dispose();
if(da != null) da.Dispose();
}
I use Visual Studio 2005 Team Suite Edition with Crystal Reports for Visual Studio 2005. Please, let's consider that I already have defined my datasets as new items within my project. However, I did not link those to my SQL Server 2005, but only constructed "fake" data tables to match the fields' name of my SQL Query with the above-suggested code. Any idea, anyone ? Should I install another version of Crystal Reports in order to make it work ? |

