Solved

Crystal Reports Runtime/database login information

Posted on 2004-09-21
5
468 Views
Last Modified: 2008-02-01
I have a windows form with a CrystalReportViewer, button, and OpenFileDialog.

I would like the user to be able to select the report to view but I want the application to supply the username/password.  I really don't want the Database Login dialog box to appear.  Is this possible?

I tried:
 Private Sub btnOpenReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpenReport.Click
        OpenFileDialog1.Filter = "Crystal Reports|*.RPT"
        If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
            CrystalReportViewer1.ReportSource = OpenFileDialog1.FileName
        End If

    End Sub

    Private Sub CrystalReportViewer1_ReportRefresh(ByVal source As Object, ByVal e As CrystalDecisions.Windows.Forms.ViewerEventArgs) Handles CrystalReportViewer1.ReportRefresh
        Dim logOnInfo As New TableLogOnInfo
        logOnInfo.ConnectionInfo.ServerName = "servername"
        logOnInfo.ConnectionInfo.DatabaseName = ""
        logOnInfo.ConnectionInfo.UserID = "username"
        logOnInfo.ConnectionInfo.Password = "password"
        CrystalReportViewer1.LogOnInfo.Add(logOnInfo)
    End Sub
0
Comment
Question by:wykzimme
5 Comments
 
LVL 1

Expert Comment

by:redundguy
ID: 12121420
Try

Instead of
CrystalReportViewer1.LogOnInfo.Add(logOnInfo)

you can use:
vnt=reportdocumentobject.Database.tables.count
for i=0 to vnt-1
    reportdocumentobject.Database.tables(i).ApplyLogonInfo(logoninfo)
next

and maybe you need:
logoninfo=reportdocumentobject.Database.tables(0).logoninfo
before:
logOnInfo.ConnectionInfo.ServerName = "servername"

George
0
 

Author Comment

by:wykzimme
ID: 12341069
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12393676
PAQed, with points refunded (50)

Computer101
E-E Admin
0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

810 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