Skip to Content
Former Member
Jun 21, 2009 at 06:23 PM

[CR2008] Changing database type at runtime fails



I'm using the code below to change database connection at runtime. It woks fine as long as the database type remains the same as the one defined when creating the report. As soon as the database type change for something else, it doesn't work anymore (for example changing from MSSQL to Firebird).

                ConnectionInfo connectionInfo = new ConnectionInfo();
                connectionInfo.ServerName = serverName;   //physical server name
                connectionInfo.DatabaseName = databaseName;
                connectionInfo.UserID = loginName;
                connectionInfo.Password = loginPassword;

                // Assigne les données de connexion à toutes les tables contenues
                // dans le rapport
                TableLogOnInfo tableLogOnInfo;
                foreach (Table table in reportDoc.Database.Tables)
                    tableLogOnInfo = table.LogOnInfo;
                    tableLogOnInfo.ConnectionInfo = connectionInfo;

To say it in other words:

When I use the report designer to set database connection to a MSSQL database and then at runtime change the parameters for another MSSQL database server hosting the same database (for example development to operational databases), it works. It also works if I do it with a Firebird database (again development to operational). But if the report is setup with MSSQL and I runtime Firebird is selected, then connection fails.

Using VS2008 debugger, putting a breakpoint on the line after ApplyLogOnInfo, I can see that collection table.LogOnInfo.ConnectionInfo.Attributes contains values from the report at design time such as "Database DLL".

I don't know which code to use the change ALL connection parameters, including database type and driver.

Any help appreciated,


Francois Piette