As i started with my new project. I choose vb.net 2005 and PHP to write my Frontend applications and MySQL for my Backend. There is no problem connecting my PHP program to a MySQL database… The problem is how can I connect my VB.net program to a MySQL database??? Connecting a VB.net program to a Microsoft SQL Server and to a Oracle is a walk in the park. After a couple of Googling and some sweat & blood hehehe… I come up with this solutions…..
First download and install a MySQL Connector for .NET here
Then in VB.NET IDE go to Project > Add Reference… In the .NET Tab Add the MySQL.Data Reference and click OK
Use this code to Open a Database Connection:
Imports MySql.Data.MySqlClient
Public Conn As MySqlConnection
Sub OpenDatabase()
Conn = New MySqlConnection()
Conn.ConnectionString = “server=localhost; Port=3306; user id=USER; password=PASSWORD; database=MyDatabase”
End Sub
How do I install the MySQL Connector?
By: NenCh on March 6, 2009
at 7:17 am
just download and install the setup then instantiate first before you use it to your program =)
By: Taong Grasa on March 10, 2009
at 12:55 pm
Have you tried the 6.0.4 connector? I’m having an error installing it, kaso kelangan talaga kasi it has relevant improvements on speedup. Any ideas on this?
By: Pugz on July 3, 2009
at 2:41 am
how to add data in the database using the forms?
By: Gayle on July 5, 2009
at 11:36 pm