VB.NET MySQL连接 [英] VB.NET MySQL connection

查看:247
本文介绍了VB.NET MySQL连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Visual Studio可以本地连接到MySQL数据库吗?还是我需要首先安装第三方连接器?有人可以以任何一种方式提供一个小的代码示例吗?我似乎无法完成这项工作.

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数据库?

Can Visual Studio natively connect to a MySQL database?

根据我的知识,不会.

Based upon my knowledge, no.

我需要安装第三方吗? 连接器优先?

Do I need to install a 3rd party connector first?

是, MySQL有自己的.NET连接器.

有人可以提供一些 两种方式的代码示例?我好像 使这项工作.

Could someone please provide a small code example either way? I can't seem to make this work.

此处是指向MySQL连接器文档的链接..

在这里,我找到了这个例子:

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

这篇关于VB.NET MySQL连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆