The purpose of this blog is to get the dev aware of how the PowerShell can be used to connect to MySQL db and insert a sample record.
With the increase of automation in industry, powershell is made responsible for doing many more things including inserting a new record in MySQL database.
The script flow start at line 28 by setting bthe username/ password/ database name, server name of the MYSQL database. By Default the port to connect db is 3306.
$query parameter of powershell need to be set for correct insert DML statement.
Next is Powershell function call which takes username, password, server, database, query as parameter. Line 1 to 26 is PowerShell function which handles this.
For this function to work perfectly it necessary for[reflection.assembly]::LoadFrom(“C:\abc\MySql.Data.dll”)
Statement to execute with success. What this statement do is load MySQL.data.dll assembly in script.
Its >net and MySQL connector Dll. You can get this dll by creating a new project in .Net Visual studio and add a new package by searching ‘MySQL’. Make sure you correctly set this DLL path in script.
This function takes care of establishing the connection with MySQL, Open the connection, execute the SQL DML query and return the response.
I tested this script in Windows 10, Powershell 4 and MySQL 8.4.5 and works fine.
By default when you install Vs2015 ( Enterprise or Community), .Net code is not installed. You need to manually install it by following the below link:
string assemblyPath = @”<exe/ dll path>”;
var assembly = Assembly.LoadFrom(assemblyPath);
var customAttributes = assembly.GetCustomAttributesData();
var dotnetFramework = customAttributes.FirstOrDefault(attr => attr.AttributeType.Equals(typeof(TargetFrameworkAttribute)));
var frameworkVersion = string.Empty;
if (null != dotnetFramework)
// first argument is the name of the framework.
frameworkVersion = (string)dotnetFramework.ConstructorArguments.Value;
Console.WriteLine(“Framework Version: “ + frameworkVersion);
This code will give you the .Net framework version the dll/exe was created in.
I tested it for 4.5, 4.6.1 , 4.5.2 and gives the correct info.
The code in this article talks about how to read multiple information in PE header, machine, no of sections, check for bit ( 32 or 64) etc..
Must read article if you want to know the intricacies of what .DLL and .exe files contain.
We all know ECMAScript 6 was released in June 2015. Many new features made part of final edition of it. Work on ECMAScript 7 has started now.
Browsers are trst to implement these features assp.
has good updates on where browsers stand. So far IE11 seems to be leading this race, followed by Chrome.
All web developers must read the ECMAScript specifications at: http://www.ecma-international.org/ecma-262/6.0/