Skip to Content

Crystal Report: Identify data sources

Hi,

We are using Crystal reports with Typed Data set to generate the report in our application, it is working as expected. But Customer added few other tables to that report using SQL data source(i.e by adding OLEDB connection) to add required tables to the report. Now if we generate the report, it is asking SQL server credentials every time.To resolve this problem we have written the below code to provide the SQL credentials to the report.

Dim reportGlobal As New ReportDocument

Dim crtableLogoninfo As TableLogOnInfo = New TableLogOnInfo

Dim crConnectionInfo As ConnectionInfo = New ConnectionInfo

Dim CrTables As Tables crConnectionInfo.ServerName = "sqlservername" crConnectionInfo.DatabaseName = "databasename"

crConnectionInfo.UserID = "sa"

crConnectionInfo.Password = "password"

crConnectionInfo.IntegratedSecurity = True

CrTables = reportGlobal.Database.Tables

For Each CrTable As CrystalDecisions.CrystalReports.Engine.Table In CrTables crtableLogoninfo = CrTable.LogOnInfo crtableLogoninfo.ConnectionInfo = crConnectionInfo CrTable.ApplyLogOnInfo(crtableLogoninfo)

Next

As per the above code, our application is getting all the tables available in typed data set and other(i.e newly added tables from SQL server). Then our connection information is setting to all the tables. We want to know is there any other way to identify SQL data source is added to the report or is there any way to identify the tables which are not included in typed data set. Please help us on above. Thanks

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Apr 13 at 02:38 PM

    In your application, have you followed a specific naming convention for the tables in your DataSet? If so, when you're looping through the tables, you could identify which ones use that naming convention and skip setting the login on those tables. Also, I believe that the "IntegratedSecurity" setting turns on single-sign-on to the database using the user's credentials instead of the credentials you are setting in the code, so you might want to try removing that from your code.

    -Dell

    Add comment
    10|10000 characters needed characters exceeded

    • You'll definitely want to change the code to set IntegratedSecurity to false.

      Beyond that, you'll want to look at the ConnectionInfo for each table as you loop through the tables. I'm not exactly sure what the difference between the two types of tables will be, but there will be a difference (debug through the code to see what it is) and that will help you determine which tables you will not set logon info for.

      -Dell