Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB.NET
VB.NET General VB.NET discussions for issues that don't fall into other VB.NET forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 29th, 2006, 07:58 PM
Registered User
Join Date: May 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to cwliong2508
Default How vb.net connect to the MySQL server database?

I using VB.NET develop my application which need to connect to the MYSQL 5.0 database server which is not localhost server. I don't know how to connect remotely to the MySQL 5.0 database server...

I have wrote some codes which show below :

Imports MySql.Data.MySqlClient
Imports MySql.Data.MySqlClient.MySqlConnection
Imports MySql.Data.MySqlClient.MySqlException
Imports MySql.Data.MySqlClient.MySqlCommand

Public Class Form1
    Inherits System.Windows.Forms.Form

    Dim conn As New MySqlConnection

Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click

  Dim sConnectionString As String _
                   ="Server=pm1-fs;User ID=root;password=iloveyou;"
        Dim conn As New MySqlConnection(sConnectionString)

            MessageBox.Show("Connection Opened Successfully")
        Catch myerror As MySqlException
            MessageBox.Show("Error Connecting to Database: " & myerror.Message)
        End Try

    End Sub
End Class

Anybody help me check.....?

Thank You.


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to connect to remote database with vb net? qiux ADO.NET 4 May 8th, 2008 08:11 PM
how to connect MySql Database through ASP.NET v2 shahhussain ASP.NET 2.0 Basics 0 September 27th, 2006 03:59 AM
VB 2005 connect to server 2003 with SQL database Derek_05 Visual Basic 2005 Basics 3 September 20th, 2006 10:10 AM
how vb.net connect access database abbee99 ADO.NET 1 April 29th, 2005 04:21 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.