Author Topic: WB CLR in-memory C# Get MYSQL version  (Read 3432 times)

stanl

  • Pundit
  • *****
  • Posts: 777
WB CLR in-memory C# Get MYSQL version
« on: June 02, 2014, 10:28:20 am »
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

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Deana F.
Technical Support
Wilson WindowWare Inc.

stanl

  • Pundit
  • *****
  • Posts: 777
Re: WB CLR in-memory C# Get MYSQL version
« Reply #2 on: June 02, 2014, 12:44:49 pm »
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

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: WB CLR in-memory C# Get MYSQL version
« Reply #3 on: June 02, 2014, 12:50:07 pm »
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

  • Tech Support
  • *****
  • Posts: 2538
    • WinBatch
Re: WB CLR in-memory C# Get MYSQL version
« Reply #4 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. 
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


stanl

  • Pundit
  • *****
  • Posts: 777
Re: WB CLR in-memory C# Get MYSQL version
« Reply #5 on: June 02, 2014, 03:01:06 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

  • Tech Support
  • *****
  • Posts: 2538
    • WinBatch
Re: WB CLR in-memory C# Get MYSQL version
« Reply #6 on: June 03, 2014, 10:48:46 am »
C# ain't got no built-in 'delete' operator.  If the class implementer did her job correctly, the GC will take out the garbage.
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates