Report Design
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Report Design
Message Icon Topic: asking every time username password Post Reply Post New Topic
Author Message
adnan
Newbie
Newbie
Avatar

Joined: 28 Nov 2008
Location: Pakistan
Online Status: Offline
Posts: 1
Quote adnan Replybullet Topic: asking every time username password
    Posted: 28 Nov 2008 at 4:53am
Hello
    why crystal report asking me every time username password when i load the data from database through vb.net?
Thanks

Edited by adnan - 28 Nov 2008 at 5:18am
a
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 02 Dec 2008 at 12:12pm
Are you using a .NET dataset or does your report connect to the database?
 
If you're using a .NET dataset, you need to make sure that you set the datasource of the report to point to the current instance of the dataset prior to setting the reportsource of the viewer.  I don't work in VB.NET, but in C# I usually overload the creator of the viewer form so that the form that generates the data can pass the dataset to the viewer.  I then create the report object, set its dataset, and then set the reportsource of the viewer.  The code looks something like this:

public CrystalDocReportViewer(DataSet ds)
{
  InitializeComponent();
  rpt
= new CrystalDocReport();
  rpt
.SetDataSource(ds);
  viewer
.ReportSource = rpt;
}
 
If you're not using a dataset, but connecting the report to the database, then you have to set the login values when you run the report.  We do it this way:

CrystalDecisions.Shared.ConnectionInfo connectionInfo = new CrystalDecisions.Shared.ConnectionInfo();
connectionInfo.ServerName = qServer;
connectionInfo.UserID = rptUserID;
connectionInfo.Password = rptPassword;
 
// set report connection for main report
Tables tables = crReport.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
{
  TableLogOnInfo tableLogonInfo = table.LogOnInfo;
  tableLogonInfo.ConnectionInfo = connectionInfo;
  table.ApplyLogOnInfo(tableLogonInfo);
}

// set report connection for any subreports
Sections sections = crReport.ReportDefinition.Sections;
foreach (Section section in sections)
{
  ReportObjects reportObjects = section.ReportObjects;      
  foreach (ReportObject reportObject in reportObjects)
  {
    if (reportObject.Kind == ReportObjectKind.SubreportObject)
    {
      SubreportObject subreportObject = (SubreportObject)reportObject;
      ReportDocument subReportDocument =
        subreportObject.OpenSubreport(subreportObject.SubreportName);
      tables = subReportDocument.Database.Tables;
      foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
      {
        TableLogOnInfo tableLogonInfo = table.LogOnInfo;
        tableLogonInfo.ConnectionInfo = connectionInfo;
        table.ApplyLogOnInfo(tableLogonInfo);
      }
    }
  }
}


-Dell

IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.