Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database Logon

Status
Not open for further replies.

organickarma

Programmer
Nov 19, 2006
34
US
Hi,

I am trying to integrate crystal reports xi into a VB .NET desktop app. I am using VS2005.

The issue I am running into is each time I run a report from the app it asks for the database logon credentials.

I have tried using the

MS driver for oracle and the OLE DB driver

The userid and password are passed throught the default conncection string created when the database connections are specified in Visual Studio

I know my question seems kinda unclear but if anybody has any kind of suggestion please help me here

Thanks
 
Hello,

Have you found an answer to this issue? I am experiencing the same problem. Just wanted to know if you were able to solve it.
 
You need to set the login as part of your code prior to opening the report.

-Dell

A computer only does what you actually told it to do - not what you thought you told it to do.
 
Hilfy,

How do you go about this process? where do you at the code for the credentials. In the report viewer or the VB form? Please help this confused user.
 
Here's the code that we use (our Code-Behind is in C#, but you should be able to translate to VB...):

Main procedure that lodes the report:
Code:
    CrystalDecisions.Shared.ConnectionInfo connectionInfo = new CrystalDecisions.Shared.ConnectionInfo();

    connectionInfo.ServerName = qServer;
    connectionInfo.UserID = qUserID;
    connectionInfo.Password = qPW;

    // set report connection for main report
    SetDBLogonForReport(connectionInfo, crReport, qServer);
    // set report connection for any subreports
    SetDBLogonForSubreports(connectionInfo, crReport, qServer);
SetDBLogonForReport:
Code:
 private void SetDBLogonForReport(CrystalDecisions.Shared.ConnectionInfo connectionInfo, ReportDocument reportDocument, string qServer)
  {

    Tables tables = reportDocument.Database.Tables;
    foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
    {
      TableLogOnInfo tableLogonInfo = table.LogOnInfo;
      tableLogonInfo.ConnectionInfo = connectionInfo;
      table.ApplyLogOnInfo(tableLogonInfo);
    }
  }
SetDBLogonForSubreports:
Code:
private void SetDBLogonForSubreports(CrystalDecisions.Shared.ConnectionInfo connectionInfo, ReportDocument reportDocument, string qServer)
  {
    Sections sections = reportDocument.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);
          SetDBLogonForReport(connectionInfo, subReportDocument, qServer);
        }
      }
    }
  }
Note that you have to set the log in info for each table in both the main report and each subreport.

The basis for this code was found on the Business Objects Developer Library website at [URL unfurl="true"]http://devlibrary.businessobjects.com/BusinessObjectsXIR2/en/devsuite.htm[/url].

-Dell



A computer only does what you actually told it to do - not what you thought you told it to do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top