Solved

Crystal Reports Runtime/database login information

Posted on 2004-09-21
5
466 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
Comment Utility
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
Comment Utility
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
Comment Utility
PAQed, with points refunded (50)

Computer101
E-E Admin
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 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

11 Experts available now in Live!

Get 1:1 Help Now