Little Code Support to Export to CSV

I found some code here that states it was working, but being a novice, I am likely not doing this right.

I have a UD Form and have a button. I copied the Event Wizard and now have reduced to 1 error on compile.

Compiling Custom Code … Line 71 is highlighted

----------errors------------

Error: BC30002 - line 71 (273) - Type ‘DynamicQueryAdapter’ is not defined.

** Compile Failed. **

Private Sub btnGenerateCsv_Click(ByVal sender As Object, ByVal args As System.EventArgs)

  ' ** Place Event Handling Code Here **

Try

’ Declare and Initialize EpiDataView Variables
’ Declare and create an instance of the Adapter.
'Line 71
Dim adapterDynamicQuery As DynamicQueryAdapter = New DynamicQueryAdapter(Me.oTrans)
adapterDynamicQuery.BOConnect

’ Declare and Initialize Variables

dim strBAQName as string
Dim result As Boolean
Dim pbSuccess As System.Boolean

strBAQName = “CCI-CommercialAP”
’ Get the ID of BAQ that you wish to work with
adapterDynamicQuery.GetQueryByID(strBAQName)

result = adapterDynamicQuery.Export(adapterDynamicQuery.RuntimeQuery,“\CCCAEPI01\Downloads\CommercialAP”, “csv”, “,”, false, pbSuccess)

’ Cleanup Adapter Reference
adapterDynamicQuery.Dispose
Catch ex As System.Exception
ExceptionBox.Show(ex)
End Try
End Sub

1 Like

Hi Miguel,

You have to add a reference to the adapter first.

If you get that, you need to use the wizards to add a custom reference.

Pick the first option

Get adapters list and pick the dynamic adapter

It will compile successfully now.

Carlos
PSE

1 Like

Thank you, that made the code compile.

Seems like the code is running, but does not bring over the results though when I run the query there is plenty of results

JUst a little bump since people are coming back from Insights

I was not aware of this, I’ll have to check that out:

result = adapterDynamicQuery.Export(adapterDynamicQuery.RuntimeQuery,"\\CCCAEPI01\Downloads\CommercialAP", "csv", ",", false, pbSuccess)

But does that also execute the query? I’d check the source but I haven’t unpacked all my junk from Insights yet,

I’ve only ever used those dynamic queries by executing then handling the results from the “results” table as seen here (in c#):