VB.NET(VB2013)连接到在线数据库(db4free.net)

时间:2014-07-22 11:22:25

标签: mysql database vb.net

如何成功连接到db4free.net?我需要先下载连接器/网络吗?我似乎无法导入MySql.Data.MySqlClient

这是我的示例代码:

Imports System.Data.SqlClient
Imports mysql

Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Try
            Dim MySQLConnection = New SqlClient.SqlConnection
            MySQLConnection.ConnectionString = "server=db4free.net ;port=3306; user id=user; password=password; database=databasetest;"
            MySQLConnection.Open()
            MsgBox("Success!")
        Catch ex As Exception
            MsgBox("Failed!")
        End Try
    End Sub
End Class

编辑 - 通过下载连接器/网络,我设法导入MySql.Data.MySqlClient。所以感谢adaam也指出了错误Dim MySQLConnection = New SqlClient.SqlConnection。 这是我的最新代码。管理以获得成功消息。我做得对还是错过了其他一些重要的步骤?

Imports System.Data.SqlClient
Imports MySql.Data.MySqlClient

Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Try
            Dim MySQLConnection = New MySqlConnection
            MySQLConnection.ConnectionString = "server=db4free.net ;port=3306; user=prav5ef; password=prav5eF; database=databasetest;"
            MySQLConnection.Open()
            MsgBox("Success!")
        Catch ex As Exception
            MsgBox("Failed!")
        End Try
    End Sub
End Class

0 个答案:

没有答案