Click to See Complete Forum and Search --> : Connecting to mysql Database in vb.net
kohlimannu
October 4th, 2005, 03:03 AM
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
wildfrog
October 4th, 2005, 04:07 AM
You can download mySQL drivers/libraries for .NET here (http://dev.mysql.com/downloads/dotnet.html).
- petter
jmcilhinney
October 4th, 2005, 04:25 AM
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.
kohlimannu
October 5th, 2005, 12:11 AM
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.
jmcilhinney
October 5th, 2005, 12:15 AM
once you've downloaded that MySQL connector you can add the components it contains to the VS.NET ToolboxIt doesn't just happen by itself. Expand the Data tab on the Toolbox, right-click within it and select Add/Remove Items.
kohlimannu
October 5th, 2005, 12:41 AM
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())
=======
jmcilhinney
October 5th, 2005, 12:56 AM
I think you're using the connection string for the MySqlConnection from eInfoDesigns. You want the one for Connector/NET 1.0.
kohlimannu
October 5th, 2005, 01:00 AM
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.
kohlimannu
October 5th, 2005, 01:06 AM
ive got the solution
now its works thanx alot all of you.
jmcilhinney
October 5th, 2005, 01:08 AM
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.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.