Link to home
Start Free TrialLog in
Avatar of cossy74
cossy74

asked on

Database Logon Information and C#

Hi,

i have this code that sets the logon information:

                                                crConnection.ServerName = g_DSN;            
                  crConnection.DatabaseName = g_Computer;
                  crConnection.UserID = g_UID;                  
                  crConnection.Password = g_PWD;                  
                                    
                  TableLogOnInfo logonInfo = new TableLogOnInfo();

                  foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in oRpt.Database.Tables)
                  {
                        logonInfo = crTable.LogOnInfo;
                        logonInfo.ConnectionInfo = crConnection;
                        crTable.ApplyLogOnInfo(logonInfo);                        
                  }            

                  crv_Viewer.ReportSource = oRpt;

My problem is that i am still getting the Popup for the database information...

Could someone help
ASKER CERTIFIED SOLUTION
Avatar of kolpdc
kolpdc

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cossy74
cossy74

ASKER

kolpdc: the problem with your code is that is there is the possibility of no tables( from c# point of view) and i get an error saying unassigned local variable crTableLogOnInfos. Any possible Help?
Avatar of cossy74

ASKER

kolpdc: changed your code to
TableLogOnInfos crTableLogOnInfos = new TableLogOnInfos();
so that the variable is assigned.
It now works...
thanks
;) yes - of course. sorry. but it gave a clue. glad i could help.