VB.NET MySQL 连接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6190599/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VB.NET MySQL connection
提问by Jimmy D
Can Visual Studio natively connect to a MySQL database or do I need to install a 3rd party connector first? Could someone please provide a small code example either way? I can't seem to make this work.
Visual Studio 可以本机连接到 MySQL 数据库还是我需要先安装第 3 方连接器?有人可以提供一个小代码示例吗?我似乎无法完成这项工作。
回答by Code Maverick
Can Visual Studio natively connect to a MySQL database?
Visual Studio 可以本机连接到 MySQL 数据库吗?
Based upon my knowledge, no.
根据我的了解,没有。
Do I need to install a 3rd party connector first?
我需要先安装第 3 方连接器吗?
Yes, 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..
In there, I found this example:
在那里,我找到了这个例子:
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
回答by Jon Black
You can install the MySQL .NET connector from the following link
您可以从以下链接安装 MySQL .NET 连接器
http://dev.mysql.com/downloads/connector/net/
http://dev.mysql.com/downloads/connector/net/
and view a previous C# related answer of mine here:
并在此处查看我以前与 C# 相关的答案:
Connecting to a Mysql DB with C# - Need some with Datasets
Sorry I dont have a VB related one but I'm sure you'd find plenty of examples here or on the web :P
对不起,我没有 VB 相关的,但我相信你会在这里或网上找到很多例子:P