Start a new topic

Code to always run?

Is there a way for me to put something in the Global.vb so that a sub will run automatically for all imports?  Or do I have to add a call from each new profile?

Hi Wayne,

You could put a Public Sub New() in the Global code and it should fire at the beginning of every import, but you will not have the session context or even know what import is being processed at that point. Other than that each profile code would need to call a common procedure in Global.



Hi Guys

I have a sub in Global.vb

Public Sub ExportSQLtoCSV(strSQL As String, strFilename As String, myImpSession As importom.API.iImportSession)

in Profile.vb (BeforeImport Event) 

call ExportSQLtoCSV("SELECT * FROM myView", "\\myServer\share\myExportFile.csv", import)

but I get error 

Name 'ExportSQLtoCSV' is not declared

I'm new to .net so am wondering how to call the Global sub from within Profile. How should I declare the Global subs/Functions? is there something I need to do with the 'Imports' statement?

Thanks for any insight

Welcome Chinh!

2 things you need to do here

1) When declaring the sub in Global.vb you need to add the keyword "Shared" to the declaration so: Public Shared Sub ExportSQLtoCSV

2) Now to call that sub from a Profile you use the reference GlobalCode. so: GlobalCode.ExportSQLtoSCV(...)

I don't think you need to use "call" in this case, just GlobalCode

If you want to share your code for exporting a SQL call to a CSV file I think people would be interested in that!

1 person likes this
cheers Wayne

I've got the code work fine now. I'll share the code under another thread.

Login or Signup to post a comment