开发者

How to connect vb.net to wamp server?

Do you know of any way on how to connect wampserver or phpmyadmin localhost to vb.net. I mean adding, searching, deleting, updating开发者_开发百科, listing of data from the localhost database via vb.net?


Huge tutorial about VB.net and MySQL: http://www.vbmysql.com/articles/vbnet-mysql-tutorials/the-vbnet-mysql-tutorial-part-1

Smaller tutorial about VB.net and MySQL: http://www.vbdotnetheaven.com/UploadFile/mahesh/AccessMySqlDatabase04252005015856AM/AccessMySqlDatabase.aspx


First of all install mysql-connector-net-6.0.7 and follow this:

Right click on the program and add reference then browse then mysql.data.dll then add module

Name it connection and copy this codes

Imports System Imports System.Data Imports MySql.Data.MySqlClient Module connection Public conn As New MySqlConnection

Public Sub ConnectDatabase()

    Try
        If conn.State = ConnectionState.Closed Then
            conn.ConnectionString = "Server=Dell-PC;Data Source=localhost:3306;Database=dbquicklend;User ID=root;"
            conn.Open()
        End If

    Catch myerror As Exception
        MsgBox("Error in Database Connection", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, "Error")
    End Try
End Sub

Public Sub DisconnectDatabase()
    Try
        conn.Close()
    Catch myerror As MySql.Data.MySqlClient.MySqlException
    End Try
End Sub

End Module

just call connectdatabase anywhere in the program you would like to connect or call disconnectdatabase when you need to disconnect

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜