Click here to Skip to main content
14,700,235 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using Crystal Report on Visual studio 2019 and I'm trying to connect to the Crystal Report file using Client Computer but it failed, the scenario is that I have a database on My computer and the client have the same database with the same tables and procedures ( but we don't have the same data ). So the difference is in the username , password and the Server Name. I can connect to the Crystal report and call the procedure from the database connected, and the data showing in the Crystal Report Viewer, but the problem appears in the Client Side, when he try to open the Crystal Viewer, he get asked for the database login ( Popup Database login ).

The Server Name and the Login ID shown in this Popup in the Client Computer is The same parameters of my connection string.

I'm trying to make the Server Name, password and the Login ID changed dynamically when the application will be installed in another computer , I mean , I would like to have access to this popup with code to modify these fields and make this programmatically,

Note: I have already posted a question with on StackOverflow and I have searched for solution in the web but I can't find what I need.

What I have tried:

C# Code ( CrystalReport.xaml.cs )

private void CrystalReportsViewer_Loaded(object sender, RoutedEventArgs e)
       {
           try
           {

               CrystalReport1 cry1 = new CrystalReport1();
               cry1.Load(@"CrystalReport1.rpt");

               GlobalConfig.sql.ConnectionString = GlobalConfig.connectionString;
               GlobalConfig gb = new GlobalConfig();
               using (IDbConnection connection = GlobalConfig.sql)
               {
                   List<string> ls = new List<string>();
                   ls = gb.getConnectionlogin();

                   cry1.SetDatabaseLogon(ls[0], ls[1]);
                   crysview.ViewerCore.ReportSource = cry1;
               }

           }
           catch(Exception es)
           {
               Console.WriteLine("Error load file   " + es);
           }


       }


https://i.stack.imgur.com/HObSq.png[^]
Posted
Updated 2-Oct-20 14:29pm

1 solution

Seems your best bet is to use Windows integrated security to connect your "app" to SQL Server, retrieve a dataset, and pass the dataset to CR.

SqlConnectionStringBuilder.IntegratedSecurity Property (System.Data.SqlClient) | Microsoft Docs[^]
   

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