Click here to Skip to main content
15,888,157 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Im using visual studio 2013, Crystal version 13.0.12, SQL server 2014.

i have a 3 sql databases. each has the exact same structure in terms of tables and views etc.
DB1
DB2
DB3

I have created a report that connects via OLEDB to DB1.
At runtime, i want the report to point to either DB2 OR DB3 depending on the user profile or access i.e. the user can only view either DB1 or DB2. Each DB has company sensitive data so in no way must the user see any other DB data.
Each DB has its own sql user and password for login/read purposes.

i have tried the following...

Dim _rd As ReportDocument = New ReportDocument()
Dim reportPath As String = Server.MapPath(Request("Report"))
_rd.Load(reportPath)
_rd.DataSourceConnections.Clear()

Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()
Dim myTables As Tables = _rd.Database.Tables

For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables
     Dim myTableLogonInfo As TableLogOnInfo = myTable.LogOnInfo
     myConnectionInfo.ServerName = "MYSERVER"
     myConnectionInfo.DatabaseName = "DB1"
     myConnectionInfo.UserID = "USERDB1"
     myConnectionInfo.Password = "PASSWORDDB1"
     myTableLogonInfo.ConnectionInfo = myConnectionInfo
     myTable.ApplyLogOnInfo(myTableLogonInfo)
Next
     CrystalReportViewer1.ReportSource = _rd


the problem is that whenever i run the report it always prompts for database login???
server: correct.
user: incorrect
password: incorrect
Database: blank

i even tried to set the property "EnableDatabasePrompt" =False but it seems to be still looking...

how do i resolve???

thanks in advance

Anoop
Posted

1 solution

I've never set login information to a specific table like that. Any reason why you can't just set the login information directly to the Crystal ReportDocument object?

Here are some examples I found via google[^]:
http://stackoverflow.com/questions/3343213/crystal-reports-setting-and-changing-the-data-source-dynamically-in-c-sharp[^]

http://stackoverflow.com/questions/40545/replace-a-database-connection-for-report-and-all-subreports[^]
 
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