Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I had a little problem when deploying an application having crystal reports as a reporting tool on a client PC.
It works so well in my dev PC even installed.Since I'm using Access 2007 i used Microsoft.ACE.OLE DB.12.0 provider.
I haven't provided any password or username for the database.But it keeps asking to provide a user name and a password.
I'm using the recent version of crystal reports (SP9) for VS and the run time for client PC.
Here is the code i used to view the report using the pull method.Any comment or modification on my coding or db connection is greatly appreciated.
VB
Dim rep As New ReportDocument

        With rep
            .Load(ReportPath)
            .SetDataSource(ds)
        End With
        CrystalReportViewer1.ReportSource = rep
        CrystalReportViewer1.Show()
Posted

Try this:
Using the DataSourceConnection Class for Database Logon[^]

Basically you need to set the logon information to get the prompt to not appear, even if you haven't password protected it. I believe your code would need to look something like this:

VB
Dim rep As New ReportDocument

With rep
    .Load(ReportPath)
    'Assuming you've setup variables with the proper server, database, user, and password
    .DataSourceConnections.Item(0).SetConnection(strServerName, strDatabase, strUser, strPassword)
    .SetDataSource(ds)
End With
CrystalReportViewer1.ReportSource = rep
CrystalReportViewer1.Show()


Hope this helps.
 
Share this answer
 
Comments
Nebilo 4-Jun-14 9:02am    
It's not working
Kschuler 4-Jun-14 9:04am    
Is it giving you an error message? Or just still popping up the logon prompt?
Nebilo 4-Jun-14 10:12am    
It's showing me the logon prompt.I also used another code but didn't make a difference.Here's the link
http://msdn.microsoft.com/en-US/library/ms227750(v=vs.80).aspx
I just used this code by providing only the server name:
VB
Dim rep As New ReportDocument
       Dim myTableLogonInfo As New TableLogOnInfo
       Dim myConnectionInfo As New ConnectionInfo
       'Dim myTables As Tables
       Dim myTable As Table
       rep.Load(ReportPath)
       rep.SetDataSource(ds)

       ' myTables = rep.Database.Tables
       With myConnectionInfo
           .ServerName = Application.StartupPath & "\projectpayrolls.accdb"
           .DatabaseName = ""
           .UserID = ""
           .Password = ""
       End With
       For Each myTable In rep.Database.Tables
           myTableLogonInfo = myTable.LogOnInfo
           myTableLogonInfo.ConnectionInfo = myConnectionInfo
           myTable.ApplyLogOnInfo(myTableLogonInfo)
       Next
       CrystalReportViewer1.ReportSource = rep
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900