Passing Database Logon Info
On p123 of 2nd edition, it describes how to pass logon info to a report.
1. Firstly, I have converted the code to c# (please see below - is it correct)
2. So I created a report using OLD DB(ADO), which is my prefered method of connection, and used the c# code. Nothing changed. The report was run, connected to database1 and used only 1 table being vat, just as if I did not have the code. What I wanted to do was run the same report against database2 which also has a vat table.
But the report simply printed out data from database1.
3. I then created a report using ODBC(RDO). This time, I get a database login screen. It shows it is against table vat and then asks for server name (which is set to (local)), database which is blank and nothing appears in the dropdown, login id of sa and blank password. Even if I type in here either database1 or 2, I get login failed.
If I do not include the code the report just works off database1.
4. here is c# code
CrystalReport3 myReport = new CrystalReport3();
CrystalDecisions.Shared.TableLogOnInfos myTableLogonInfos = new CrystalDecisions.Shared.TableLogOnInfos();
CrystalDecisions.Shared.TableLogOnInfo myTableLogonInfo = new CrystalDecisions.Shared.TableLogOnInfo();
CrystalDecisions.Shared.ConnectionInfo myConnectionInfo = new CrystalDecisions.Shared.ConnectionInfo();
myConnectionInfo.ServerName = "(local)";
myConnectionInfo.DatabaseName = "database2";
myConnectionInfo.UserID = "sa";
myConnectionInfo.Password = "";
myTableLogonInfo.ConnectionInfo = myConnectionInfo;
myTableLogonInfo.TableName = "vat";
crystalReportViewer1.LogOnInfo = myTableLogonInfos;
crystalReportViewer1.ReportSource = myReport;
5. Also, what would the foreach code look like?