Visual Studio 可以本地连接到 MySQL 数据库还是我需要先安装第 3 方连接器?有人可以提供一个小代码示例吗?我似乎无法完成这项工作。
最佳答案
Can Visual Studio natively connect to a MySQL database?
据我所知,没有。
Do I need to install a 3rd party connector first?
是的, MySQL has their own .NET Connector.
Could someone please provide a small code example either way? I can't seem to make this work.
Here is the link to the MySQL Connector documentation. .
在那里,我找到了这个例子:
Imports System.Data
Imports MySql.Data
Imports MySql.Data.MySqlClient
Public Class Tutorial1
Public Shared Sub Main()
Dim connStr As String = "server=localhost;user=root;database=world;port=3306;password=******;"
Dim conn As New MySqlConnection(connStr)
Try
Console.WriteLine("Connecting to MySQL...")
conn.Open()
Catch ex As Exception
Console.WriteLine(ex.ToString())
End Try
conn.Close()
Console.WriteLine("Done.")
End Sub
End Class
关于mysql - VB.NET MySQL连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6190599/