Connecting to mysql Database in vb.net
can anyone tell me how to connect to mysql database in vb.net
actually i tried as
imports system.data.odbc
imports system.data
Dim MyConString As String = "SERVER=server;DATABASE=x;UID=root;PASSWORD=x"
Dim MyConnection As New OdbcConnection(MyConString)
MyConnection.Open()
====
iwas searching on google i found that you can
imports mysql.data.mysqlclient
but i didnt find any class as mySql
pls help me
Re: Connecting to mysql Database in vb.net
You can download mySQL drivers/libraries for .NET here.
- petter
Re: Connecting to mysql Database in vb.net
Just to extend on wildfrog's post a little, once you've downloaded that MySQL connector you can add the components it contains to the VS.NET Toolbox along with the SqlClient, OleDb, OdbcClient, etc. components. You can then add them to your forms or add a reference to the library to your peoject and create the objects in code. You can find the appropriate connection string to use with the MySqlConnection at www.connectionstrings.com.
Re: Connecting to mysql Database in vb.net
Quote:
Originally Posted by jmcilhinney
Just to extend on wildfrog's post a little, once you've downloaded that MySQL connector you can add the components it contains to the VS.NET Toolbox along with the SqlClient, OleDb, OdbcClient, etc. components. You can then add them to your forms or add a reference to the library to your peoject and create the objects in code. You can find the appropriate connection string to use with the MySqlConnection at
www.connectionstrings.com.
ive already donwload and install that library but i didnt find any MySqlConnection provider in my VS.NEt Toolbox.
any idea to resolve this.
Re: Connecting to mysql Database in vb.net
Quote:
Originally Posted by jmcilhinney
once you've downloaded that MySQL connector you can add the components it contains to the VS.NET Toolbox
It doesn't just happen by itself. Expand the Data tab on the Toolbox, right-click within it and select Add/Remove Items.
Re: Connecting to mysql Database in vb.net
Quote:
Originally Posted by jmcilhinney
It doesn't just happen by itself. Expand the Data tab on the Toolbox, right-click within it and select Add/Remove Items.
thnax i found the mysqlconnection
but when i m creating a connection through the code i m getting the following error.
"An unhandled exception of type 'System.Net.Sockets.SocketException' occurred in mysql.data.dll
Additional information: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied"
=======My Code is======
Imports MySql.Data.MySqlClient
Dim MyConString As String = "SERVER=server;DATABASE=x;UID=root;PASSWORD=x;port=3030"
Dim myconn As New MySqlConnection(MyConString)
myconn.Open()
MsgBox(myconn.State.ToString())
=======
Re: Connecting to mysql Database in vb.net
I think you're using the connection string for the MySqlConnection from eInfoDesigns. You want the one for Connector/NET 1.0.
Re: Connecting to mysql Database in vb.net
Quote:
Originally Posted by jmcilhinney
I think you're using the connection string for the MySqlConnection from eInfoDesigns. You want the one for Connector/NET 1.0.
ive installed net connector 1.0.6. can u explain the solution.
Re: Connecting to mysql Database in vb.net
ive got the solution
now its works thanx alot all of you.
Re: Connecting to mysql Database in vb.net
Go to www.connectionstrings.com, as I posted earlier, and look at the connection strings for MySQL. The one you are using matches the one for MySqlConnection from eInfoDesigns, but you should be using the one for Connector/NET 1.0, which is what you are now using.