Solved

Crystal Report asking for DB login

Posted on 2015-01-24
7
143 Views
Last Modified: 2015-07-07
Hi,

I am using Visual Studio 2008 with Crystal Report engine provided with VS.
I create couple of reports that display properly in the crystalreportviewer on my development machine.
But, when I publish my site to the production server the report won't open and the system ask for the DB username and password login.

On my development machine I am using window integrated security while on the production server I am using "sa" login to connect to the DB.

I added the following code lines to my code, but the report is still asking for the DB login:

cryRpt.SetDatabaseLogon("sa", "dbadmin", "Hyper_Server", "myDB")

I need help please!
0
Comment
Question by:pascalmartin
7 Comments
 
LVL 32

Expert Comment

by:Daniel Wilson
ID: 40568200
You need to set each table's logon info.

Something like ...
        Dim crtableLogoninfo As New TableLogOnInfo
        Dim crConnectionInfo As New ConnectionInfo
        with crConnectionInfo
           .Server = "Hyper_Server"
           .DatabaseName = "myDB"
           .UserName = "" 'for Integrated security
           .password = ""
         end with

For Each dbTable As Table In cryRpt.Database.Tables
  crtableLogoninfo = dbTable.LogOnInfo
   crtableLogoninfo.ConnectionInfo = crConnectionInfo

   dbTable.ApplyLogOnInfo(crtableLogoninfo)
next

Open in new window


That code block is cut up and put back together from a complex project, so I probably missed something.  But hopefully it's close enough to get you headed in the right direction.
0
 

Author Comment

by:pascalmartin
ID: 40568263
Thanks, I shall try that Monday when back at work where is the production server...
Keep you posted.
0
 
LVL 78

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points
ID: 40569303
NO POINTS
Another way
 'Declarations
  Public CRReport As CrystalDecisions.CrystalReports.Engine.ReportDocument
  Public CRTable As CrystalDecisions.CrystalReports.Engine.Table
  Public CRTLI As CrystalDecisions.Shared.TableLogOnInfo

  'some procedure
  CRReport = New CrystalDecisions.CrystalReports.Engine.ReportDocument
  CRReport.Load(GRutaRpts & "MyReport.rpt", CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy)
  For Each Module1.CRTable In CRReport.Database.Tables
    CRTLI = CRTable.LogOnInfo
    With CRTLI.ConnectionInfo
       .ServerName = "MyDSNName"
       .UserID = "MyUserName"
       .Password = "MyPassword"
       .DatabaseName = "MyDBName"
    End With
    CRTable.ApplyLogOnInfo(CRTLI)
  Next CRTable

Open in new window

http://bit.ly/18fN8yj
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:pascalmartin
ID: 40571860
Hi Guys,

The two codes are very similar, I tried David's code but still can't get my report open without asking for the DB login info.
On my development machine I entered my local DB info and the reports opens fine, after changing the DB info to the production server in the code behind, I published the website to the production server but then the report still ask for the DB login.
0
 

Author Comment

by:pascalmartin
ID: 40585678
Any possible solution for me....
0
 
LVL 4

Expert Comment

by:habibb
ID: 40845329
try to use below code:

private void LoadCrystalReports(string reportName)
        {


            ConnectionInfo myConnectionInfo = new ConnectionInfo();
            ReportDocument myReport = new ReportDocument();
            myReport.Load(Server.MapPath(reportName));
            // name of the crystal report

            Tables myTables = myReport.Database.Tables;

            foreach (CrystalDecisions.CrystalReports.Engine.Table myTable in myTables)
            {
                TableLogOnInfo myTableLogonInfo = myTable.LogOnInfo;
                myConnectionInfo.ServerName = "Servername"; //Your server
                // <SQL servername>
                myConnectionInfo.DatabaseName = ""; //Leave DB Blank
                // leave database name blank
                myConnectionInfo.UserID = "Username"; //Your User
                // username
                myConnectionInfo.Password = "Password"; //Your Users Password
                // password
                myTableLogonInfo.ConnectionInfo = myConnectionInfo;
                myTable.ApplyLogOnInfo(myTableLogonInfo);
            }

            Session["reportDocument"] = myReport;
            reportViewer.ReportSource = myReport;
            //reportViewer.RefreshReport();

        }

The difference above code has login info settings at each table level. Also try to use credentials code at below event:
protected void Page_Init(object sender, EventArgs e)



Report.discard
0
 

Author Comment

by:pascalmartin
ID: 40871750
I've requested that this question be deleted for the following reason:

No answer
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Have you ever wanted to create graphical elements directly in inDesign? This tutorial will teach you how to have an image bound within text using the pathfinder tool in inDesign CS6. This technique will help decrease the amount of time spent opening…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now