ADO connectionstring / application path

Posted by: sabena on 4 August 2017, 2:32 pm EST

  • Posted 4 August 2017, 2:32 pm EST

    Hello,

    I am new to Actve reports and I could use some help.
    I use vb 6.0 and I created a report using an ADO data control.  In the ado datacontrol I define the connectionstring which provider to use and where to find my database. This works just fine.  Now I want to run my compiled program from another location, which gives an error because my datacontrol points to my HDD for the database, whilst the application path changed
    I change the connectionstring at run-time in order to have the results from some queries printed and this also works fine.
    Main problem stays the ADO data control connectionstring which gives an error when left blank...in the designer, because string is manipulated at run-time.
    is there any way I can "send" the application  path to the AR ADO datacontrol connectionstring?

    Many thanks,

    Stijn
  • Replied 4 August 2017, 2:32 pm EST

    The Connectionstring is just that a string variable that holds the specifics of the connection. This string could be generated in a variety of ways, design time and static, dymanic at run time via view a connection dialog, input box, series of message boxes...a selection from a list...etc.

    You can load your custom connectionstring in the ReportStart event of a report.  You can also load a custom source, which I like to do which allows me to variably define the parameters via SQL.
  • Replied 4 August 2017, 2:32 pm EST

    I'm new to Active Reports and am taking on an existing part-developed application. I have to configure the connectionString at Runtime, it is currently hard-coded into the Report.

    The code that loads the report is as follows:

    Private Sub HL_IBSReport_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        frmReportViewer.ReportName = "IBSReport.rpx"
        frmReportViewer.LoadReport
        frmReportViewer.Show
    End Sub

    Then in the frmReportViewer:

    Public Sub LoadReport(Optional ByVal bLoadSubReports As Boolean = False)
            '
            On Error GoTo LoadReport_Err
            '

            Dim oRpt As New ActiveReport
            Dim oLink As New SubLink
        
           If m_ReportName = "" Then Exit Sub
            'Load Main Report from .RPX File
          oRpt.LoadLayout VB.App.Path & "\Reports\" & m_ReportName
            
           If bLoadSubReports = True Then
                'Link all Subreports for Main Report
               oRpt = oLink.StaticSubLink(oRpt)
            End If
        
            'Load Report into Viewer
            ARViewer21.DataPath = VB.App.Path & "\Data"
            Set Me.ARViewer21.ReportSource = oRpt
            Me.ARViewer21.Refresh
            '
            Exit Sub
    etc

    Nothing I try lets me get at the connectionString.

    Do I need to rewrite this bit of code?

    Thanks

    FG
  • Replied 4 August 2017, 2:32 pm EST

    Since you are loading from an RPX file I believe you will have to use script to get to the ConnectionString. There should be an article or two on the subject in the KnowledgeBase.

    http://www.datadynamics.com/ShowPost.aspx?PostID=491
    http://www.datadynamics.com/ShowPost.aspx?PostID=429
  • Replied 4 August 2017, 2:32 pm EST

    Like wsmith said, the best way would be to change the connection string in script code. The alternative is to reference the data control on the report through the sections and controls collection. This requires that all your data controls be of the same type and have the same control name. The syntax looks something like this:
    oRpt.Sections("Detail").Controls("MyDataControl").ConnectionString = "my connection string"
Need extra support?

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

Learn More

Forum Channels