Changing datasource in designer at runtime

Posted by: darin on 9 November 2022, 9:47 am EST

    • Post Options:
    • Link

    Posted 9 November 2022, 9:47 am EST

    We have our program setup so when the designer opens, we set the connectionstring and load the datasource.

    Try

    Dim ds As New GrapeCity.ActiveReports.Data.SqlDBDataSource

    ds = CType(reportDesigner.Report.DataSource, GrapeCity.ActiveReports.Data.SqlDBDataSource)
    ds.ConnectionString = ConnectString()
    ds.SQL = "SELECT TOP 5 * FROM Customer WITH (NOLOCK)"
    reportDesigner.Report.DataSource = ds
    

    Catch oExcept As Exception

    MsgBox(oExcept.Message)

    End Try

    But, this fails and displays the message:

    Not allowed to change the ‘ConnectionString’ property. The connection’s current state is open.

    How can i close the current state to get the correct connection string and datasource loaded?

  • Posted 11 November 2022, 3:34 am EST

    Hi Darin,

    I tested this issue out with ActiveReports 16.2.1 EndUserDesigner Sample and I wasn’t able to replicate this behavior at my end. I have attached the sample application for reference.

    In the attached sample, I am changing the DataSource’s connectionString on ReportLoad and on ReportClear type Designer layout change. And, I was able to successfully change the Connection String.

    Please refer to the attached sample. If the issue still persists please share a sample application replicating the issue or edit the attached sample such that it reproduces this issue and send it back to us for further investigation on this.

    Regards,

    Akshay

    DataSourceChange.zip

  • Posted 11 November 2022, 7:20 am EST

    Thank you. That seems to be working. I was changing it in the wrong place. Appreciate your help.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels