WB CLR in-memory C# Get MYSQL version

Started by stanl, June 02, 2014, 10:28:20 AM

Previous topic - Next topic

stanl

Playing around some more. The attached script reads the attached text file (C# code) into memory and executes a method to return the version of MySQL. Not a big deal, unless you consider you are connecting to the server with .NET

If you have MySQL installed you can replace the [user], [pwd] in the text file with real values, and just insure you have the MySQL .Net Connector installed.

One question: even though the script worked for me (with real credentials), the C# code is probably written wrong in that the 'finally' section probably doesn't get executed. Should I have then closed the connection in both the try and catch sections.

Deana

Deana F.
Technical Support
Wilson WindowWare Inc.

stanl

Quote from: Deana on June 02, 2014, 10:45:29 AM
Why not just call the MySql.Data.MySqlClient directly in WinBatch?

I can, and I have. I just find the in-memory stuff fascinating.

Deana

Well not sure I can answer your C# question; I will leave that to those versed in C#.
Deana F.
Technical Support
Wilson WindowWare Inc.

td

Try-catch-finally blocks are based on MSFT's  structured exception handling C-language extension.  The finally block gets executed whether or not an exception occurs in the guarded try block.  The catch block only gets executed when an exception is thrown from within the try block. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

Quote from: td on June 02, 2014, 01:10:47 PM
Try-catch-finally blocks are based on MSFT's  structured exception handling C-language extension.  The finally block gets executed whether or not an exception occurs in the guarded try block.  The catch block only gets executed when an exception is thrown from within the try block.

Thank you. So if an exception occurs can it be assumed the .NET garbage collection (mentioned in an earlier thread) takes care of the connection object - much like WB cleans up.

td

C# ain't got no built-in 'delete' operator.  If the class implementer did her job correctly, the GC will take out the garbage.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade