Solved

CR XI Report from SQL Stored Procedure

Posted on 2011-09-07
14
283 Views
Last Modified: 2012-05-12
I can't seem to get this report to get the logon info passed.  The report is based on a SQL Stored Procedure.  My users keep getting the Database login dialog box.  It has the Servername, Login ID and Password but the database is blank (and you cannot enter it).  I've been trying the suggestions on this website to no avail.  The User passed in has dbo rights to the db and rights to execute the stored proc.  I've tried it with a sub report and without a sub report.  VS2005  CR XI

Here is my function
 Friend Function ViewReport(ByVal sReportName As String) As Boolean

        'Declaring variables
        Dim intCounter As Integer
        Dim intCounter1 As Integer

        'Crystal Report's report document object
        Dim objReport As New _
                    CrystalDecisions.CrystalReports.Engine.ReportDocument

        'object of table Log on info of Crystal report
        Dim ConInfo As New CrystalDecisions.Shared.TableLogOnInfo

        'Sub report object of crystal report.
        Dim mySubReportObject As _
                  CrystalDecisions.CrystalReports.Engine.SubreportObject

        'Sub report document of crystal report.
        Dim mySubRepDoc As New CrystalDecisions.CrystalReports.Engine.ReportDocument      
       
        Dim index As Integer

        Try

         
            'Load the report
            objReport.Load(sReportName)

                     
            objReport.SetDatabaseLogon("XXUSER", "USERPWD")


            ConInfo.ConnectionInfo.UserID = "XXUSER"
            ConInfo.ConnectionInfo.Password = "USERPWD"
            ConInfo.ConnectionInfo.ServerName = "SqlServer1"
            ConInfo.ConnectionInfo.DatabaseName = "DB109"
               

       

            ' Loop through each section on the report then look
            ' through each object in the section
            ' if the object is a subreport, then apply logon info
            ' on each table of that sub report

            For index = 0 To objReport.ReportDefinition.Sections.Count - 1
                For intCounter = 0 To _
                      objReport.ReportDefinition.Sections(index).ReportObjects.Count - 1
                    With objReport.ReportDefinition.Sections(index)
                        If .ReportObjects(intCounter).Kind = _
                           CrystalDecisions.Shared.ReportObjectKind.SubreportObject Then
                            mySubReportObject = CType(.ReportObjects(intCounter), _
                            CrystalDecisions.CrystalReports.Engine.SubreportObject)
                            mySubRepDoc = _
                             mySubReportObject.OpenSubreport(mySubReportObject.SubreportName)

                            For intCounter1 = 0 To mySubRepDoc.Database.Tables.Count - 1
                                mySubRepDoc.Database.Tables(intCounter1).ApplyLogOnInfo(ConInfo)
                              ' Tried setting twice
                              '  mySubRepDoc.Database.Tables(intCounter1).ApplyLogOnInfo(ConInfo)
                            Next
                        End If
                    End With
                Next
            Next
           
           
            CrystalReportViewer1.ReportSource = Nothing

            objReport.SetDatabaseLogon("XXUSER", "USERPWD")

            'Set the current report object to report.

            CrystalReportViewer1.ReportSource = objReport

            CrystalReportViewer1.Show()
            Return True
        Catch ex As System.Exception
            MsgBox(ex.Message)
        End Try
    End Function


Thanks
0
Comment
Question by:dgoncher
[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
  • 8
  • 4
  • 2
14 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 36498572
Are you changing the database or the server being used?

mlmcc
0
 

Author Comment

by:dgoncher
ID: 36498581
No
0
 
LVL 18

Expert Comment

by:vasto
ID: 36498751
You are applying the connection info to the subreports but not to the main report
0
[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

 

Author Comment

by:dgoncher
ID: 36499007
I added objReport.Database.Tables(intCounter1).ApplyLogOnInfo(ConInfo) but still the same result
0
 

Author Comment

by:dgoncher
ID: 36499083
I did that in a loop (forgot to say that

 For intCounter1 = 0 To objReport.Database.Tables.Count - 1
               objReport.Database.Tables(intCounter1).ApplyLogOnInfo(ConInfo)
Next
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 36499359
For intCounter1 = 1 To objReport.Database.Tables.Count

Crystal arrays are indexed from 1 so using 0 may cause problems

mlmcc
0
 

Author Comment

by:dgoncher
ID: 36504277
objReport.Database.Tables is zero based in my application.

I resolved the issue.  Apparently CR is useing the 2005 SQL Native Client.  After downloading and installing on eah machine the app works fine.
0
 

Author Comment

by:dgoncher
ID: 36509943
I've requested that this question be closed as follows:

Accepted answer: 0 points for dgoncher's comment http:/Q_27296164.html#36504277

for the following reason:

Issue resolved by myself
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 36506199
FYI - I believe the Native client requires a license from MS to be legal.

mlmcc
0
 

Author Comment

by:dgoncher
ID: 36506343
Great,  why would crystal require that?
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 36507280
Crystal doesn't.  The native client is a MS client.  The license is from MS.
Unless they have released a license free version.  We started down that path with Crystal 8 and decided we didn't need to buy 5-600 licenses that had to be installed and updated.

mlmcc
0
 
LVL 18

Accepted Solution

by:
vasto earned 500 total points
ID: 36507667
You don't need sql native client in order to run a report based on stored procedure. It is a developer choice what connection type will be used. Change the connection to OLDE DB SQLServer and the report will work fine.
0
 

Author Comment

by:dgoncher
ID: 36509944
I need to accept the last response as the solution.  Mine had flaws
0
 

Author Closing Comment

by:dgoncher
ID: 36509961
Changed the connetion and all is well!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

623 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