Solved

Crystal Report asking for DB login

Posted on 2015-01-24
7
186 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 80

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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The ability to automatically add page numbers to a layout is one of the many easy, convenient features InDesign has to offer. There are many reasons why you would want to automatically generate page numbers in your next project, so whether it’s a ma…
Thoughout my experience working on eCommerce web applications I have seen applications succumbing to increased user demand and throughput. With increased loads the response times started to spike, which leads to user frustration and lost sales. I ha…
This video teaches users how to migrate an existing Wordpress website to a new domain.
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…

726 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