Forum Discussion

Bella_Yu's avatar
Bella_Yu
New Contributor II
8 months ago

Call Data Adapter in BR and Store Results in External Database Table

I would like to export data from existing OneStream dashboard and load it into external database table. I did some research and below is a draft business rule written in Visual Basic. What it does is to call data adapter and store the results. Next step is to load data from DataTable into external database table.

Questions is, it gives a warning "Function GetAdoDataSetForAdapter is obsolete", what is the current supported function? 

 

Dim dctVars As New Dictionary(Of String, String)
Using ds As DataSet = brapi.Dashboards.Process.GetAdoDataSetForAdapter(si, False, "AdapterName", "ResultsTable", dctVars)
	If ds.Tables.Count > 0 Then ' -- If there are >0 tables in the results
		Using dt As DataTable = ds.Tables(0).Copy()
		Return dt 
		End Using
	End If
End Using

 

  • In the Business Rules editor if you type:

    brapi.Dashboards.Process.GetAdoDataSetForAdapter(

    it will give you the intellisense for the function which is like this:

    1 - says 1 of 2 so there is another definition of this function with different parameters (ie overloaded)

    2 - says the current definition is deprecated which is why you are getting the warning.

    Click on the down arrow in area 1 and it gives you this:

    which tells you the function needs the workspace id before the workspace/dashboard name.

     

  • MarcusH's avatar
    MarcusH
    Contributor III

    In the Business Rules editor if you type:

    brapi.Dashboards.Process.GetAdoDataSetForAdapter(

    it will give you the intellisense for the function which is like this:

    1 - says 1 of 2 so there is another definition of this function with different parameters (ie overloaded)

    2 - says the current definition is deprecated which is why you are getting the warning.

    Click on the down arrow in area 1 and it gives you this:

    which tells you the function needs the workspace id before the workspace/dashboard name.

     

    • Bella_Yu's avatar
      Bella_Yu
      New Contributor II

      Thanks for your detailed explanation, really helpful!

  • RobbSalzmann's avatar
    RobbSalzmann
    Valued Contributor II

    Hi Bella_Yu ,

    Returning an object that is managed by an enclosing using block is going to lead to problems.  Most likely if the calling code doesn't finish with dt before the enclosing Using disposes of it, you will get somewhat random errors.

    Instead, return an object that is not managed by a Using block:

    Dim dctVars As New Dictionary(Of String, String)
    Using ds As DataSet = brapi.Dashboards.Process.GetAdoDataSetForAdapter(si, False, "AdapterName", "ResultsTable", dctVars)
        If ds.Tables.Count > 0 Then ' -- If there are >0 tables in the results
            Using dt As DataTable = ds.Tables(0)
                Dim clonedDt As DataTable = dt.Copy() ' Clone the DataTable
                Return clonedDt
            End Using
        End If
    End Using

    Ideally, you should simply return dt without the using block and manage it in the calling method.