Creating custom MySQL servers in VB.NET at runtime

Viewed 65

I was wondering if it is possible to create custom MySQL servers in VB.NET while working in visual studio at runtime so that if the server already exists it connects and if it isn't there, the code creates the server. I have searched for this everywhere but couldn't find anything. I would appreciate it a lot if someone guides me to the right path.

1 Answers

You could certainly write some .net code to start a MySQL server on your Windows box when an attempt to connect fails. You simply get a cmd.exe console with administrator privileges and give the command net start mysql.

But MySQL must already be installed on the box for that to work.

You might investigate Sqlite. It provides SQL locally to a .net program, storing your tables in a file called whatever.db. It has very similar .net API access to MySQL's Connector/Net and SQL Server's connector. It's in a NuGet package.

I don't completely understand your "custom MySQL servers" requirement. Sqlite gives you a way to use SQL in your application without connecting to a shared server. That may do what you need.

MySQL does have a CREATE SERVER statement in its SQL dialect. The purpose of this statement is to create a connection to another, remote, MySQL server. With that connection you can use the FEDERATED storage engine to access tables in the remote server. Of course, there is no way to run this CREATE SERVER statement unless your program is already connected to a MySQL server.

With respect, your "task which states to create a server at runtime" doesn't make much sense. Is there more to this requirement? What workflow needs this step? Is it part of the installation of some application software on a new box?

Related