David Emerson
newsgrps at dalyn.co.nz
Wed Jul 18 14:20:04 CDT 2007
I use an add on from DataDynamics called ActiveReports which alows me to produce dot net reports in a similar interface to Access (sort of). I have a connection string defined in my Web.Config file. I want to set the connection string of the report to this when the report is run. I have the following code which is supposed to check whether the report has a connection string already. If the report doesn't have a connection string then I don't want to add a connection string (because there is no data for the report), otherwise I want to replace the connection string with the one in the Web.Config. If CType(rpt.DataSource, DataDynamics.ActiveReports.DataSources.SqlDBDataSource).ConnectionString.ToString <> "" Then CType(rpt.DataSource, DataDynamics.ActiveReports.DataSources.SqlDBDataSource).ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings("IFADBConnection").ConnectionString End If The problem is with the first line. If there is a connection string then it is replaced. If the report doesn't have a connection string then an error is raised at the first line saying "Object reference not set to an instance of an object". My guess is that this is because no data source is set at all for the report there is no ConnectionString object to compare to. Can anyone please help with the syntax for checking whether the data source object exists (then if it does I can make the replacement to the connectionString). Regards David Emerson Dalyn Software Ltd Wellington, New Zealand