Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connecting vb.net to a MySQL database 1

Status
Not open for further replies.

CIMTEET

Programmer
Jun 25, 2001
182
US
I was looking for a way to use the database connection wizard in express 2008 vb.net. It wouldn't let me add the MySQL service. Also, it only gave me 3 database options to connect to, none of which was MySQL.

Help.

Greg
 
Probably a limitation build into the Express version. Connect to it from within code instead of the wizard. You can find connection strings at connectionstrings.com
 
which one, there seems to be a lot of .net strings. Its a local connection, so I shouldn't need to worry about inlcuding a port number. I saw a .net oledbconnection but I thought oledb was for access. Well, I'll try one and see what happens.
 
I don't think I made a user name or password. Well I know there a password to login in for the Mysql connection client, but no username.
 
The MYSQL provider in the connection string...is that an address to the bin file?
 
I've never used MySQL, so I don't know which is the most common method for connecting. OLEDB is used for much more than Access. Most modern DBMS's provide an OLEDB driver. You'll want to go with one of the drivers which is installed on your system.
 
You need to connect via code, I find this to be the easiest way.

Here's an example:

Module MyModule

Public CONN As New Data.Odbc.OdbcConnection("DSN=MyDSN;DATABASE=MyDB;USER=DBUser;PASSWORD=DBPassword")
Public ADP As New Data.Odbc.OdbcDataAdapter("", CONN)
Public CMD As New Data.Odbc.OdbcCommand("", CONN)

End Module

You also need to set up your ODBC connection from Windows Administrative Tools. Just add a new User DSN with a MySQL ODBC driver where you specify which DB, user, password and of course, DSN name.

I hope this helps and that it can be understood, it has been a while since I last posted a response, so I'm a little bit rusty.

-Rob.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top