CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Sep 2002
    Location
    India (Delhi)
    Posts
    199

    Thumbs down 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
    Keep Posting in this Forum

  2. #2
    Join Date
    Apr 2005
    Location
    Norway
    Posts
    3,934

    Re: Connecting to mysql Database in vb.net

    You can download mySQL drivers/libraries for .NET here.

    - petter

  3. #3
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    1,080

    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.
    Tutorials: Home & Learn | Start VB.NET | Learn VB.NET | C# Station | GotDotNet | Games in VB.NET 101 Samples: 2002 | 2003 | 2005 | More .NET 2.0 (VB.NET, C#) Articles: VB.NET | C# | ASP.NET | MoreFree Components: WFC | XPCC | ElementsEx | VBPP | Mentalis | ADO.NET/MySQL | VisualStyles | Charting (NPlot, ZedGraph) | iTextSharp (PDF) | SDF (CF) ● Free Literature: VB 2005 (eBook) | VB6 to VB.NET (eBook) | MSDN Magazine (CHM format) ● Bookmarks: MSDN | WinForms .NET | ASP.NET | WinForms FAQ | WebForms FAQ | GotDotNet | Code Project | DevBuzz (CF) ● Code Converter: C#/VB.NET | VB.NET/C# | VS 2005 add-in

  4. #4
    Join Date
    Sep 2002
    Location
    India (Delhi)
    Posts
    199

    Thumbs down 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.
    Keep Posting in this Forum

  5. #5
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    1,080

    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.
    Tutorials: Home & Learn | Start VB.NET | Learn VB.NET | C# Station | GotDotNet | Games in VB.NET 101 Samples: 2002 | 2003 | 2005 | More .NET 2.0 (VB.NET, C#) Articles: VB.NET | C# | ASP.NET | MoreFree Components: WFC | XPCC | ElementsEx | VBPP | Mentalis | ADO.NET/MySQL | VisualStyles | Charting (NPlot, ZedGraph) | iTextSharp (PDF) | SDF (CF) ● Free Literature: VB 2005 (eBook) | VB6 to VB.NET (eBook) | MSDN Magazine (CHM format) ● Bookmarks: MSDN | WinForms .NET | ASP.NET | WinForms FAQ | WebForms FAQ | GotDotNet | Code Project | DevBuzz (CF) ● Code Converter: C#/VB.NET | VB.NET/C# | VS 2005 add-in

  6. #6
    Join Date
    Sep 2002
    Location
    India (Delhi)
    Posts
    199

    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())


    =======
    Keep Posting in this Forum

  7. #7
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    1,080

    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.
    Tutorials: Home & Learn | Start VB.NET | Learn VB.NET | C# Station | GotDotNet | Games in VB.NET 101 Samples: 2002 | 2003 | 2005 | More .NET 2.0 (VB.NET, C#) Articles: VB.NET | C# | ASP.NET | MoreFree Components: WFC | XPCC | ElementsEx | VBPP | Mentalis | ADO.NET/MySQL | VisualStyles | Charting (NPlot, ZedGraph) | iTextSharp (PDF) | SDF (CF) ● Free Literature: VB 2005 (eBook) | VB6 to VB.NET (eBook) | MSDN Magazine (CHM format) ● Bookmarks: MSDN | WinForms .NET | ASP.NET | WinForms FAQ | WebForms FAQ | GotDotNet | Code Project | DevBuzz (CF) ● Code Converter: C#/VB.NET | VB.NET/C# | VS 2005 add-in

  8. #8
    Join Date
    Sep 2002
    Location
    India (Delhi)
    Posts
    199

    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.
    Keep Posting in this Forum

  9. #9
    Join Date
    Sep 2002
    Location
    India (Delhi)
    Posts
    199

    Re: Connecting to mysql Database in vb.net

    ive got the solution
    now its works thanx alot all of you.
    Keep Posting in this Forum

  10. #10
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    1,080

    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.
    Tutorials: Home & Learn | Start VB.NET | Learn VB.NET | C# Station | GotDotNet | Games in VB.NET 101 Samples: 2002 | 2003 | 2005 | More .NET 2.0 (VB.NET, C#) Articles: VB.NET | C# | ASP.NET | MoreFree Components: WFC | XPCC | ElementsEx | VBPP | Mentalis | ADO.NET/MySQL | VisualStyles | Charting (NPlot, ZedGraph) | iTextSharp (PDF) | SDF (CF) ● Free Literature: VB 2005 (eBook) | VB6 to VB.NET (eBook) | MSDN Magazine (CHM format) ● Bookmarks: MSDN | WinForms .NET | ASP.NET | WinForms FAQ | WebForms FAQ | GotDotNet | Code Project | DevBuzz (CF) ● Code Converter: C#/VB.NET | VB.NET/C# | VS 2005 add-in

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured