如何连接到MySql数据库.Net [英] How can I connect to MySql Database .Net

查看:102
本文介绍了如何连接到MySql数据库.Net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,我正试图通过我的visual studio应用程序连接到mySql数据库。我的连接字符串如下。



Hey guys, I am trying to connect to a mySql database through my visual studio application. My connection string is as follows.

sConnString = @"Server=localhost;Port=3306;Database=test;Uid=username;Pwd=password;";





我收到以下错误:



附加信息:ERROR [IM002] [Microsoft] [ODBC驱动程序管理器]未找到数据源名称并且没有指定默认驱动程序



任何想法我做错了什么?





先谢谢你们。



I get the following error:

Additional information: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Any ideas what I'm doing wrong?


Thanks in advance guys.

推荐答案

你没有告诉它使用什么驱动程序。它不知道如何连接。



首先,你需要决定是否使用ODBC或ADO.NET与数据库通信。



然后你需要安装 ODBC [ ^ ]或 ADO.NET [ ^ ]驱动程序。



然后您需要按照驱动程序附带的说明进行连接。通常类似于:

You are not telling it what driver to use. It doesn't know how to connect.

First you need to decide if you are using ODBC or ADO.NET to talk to the database.

Then you need to install the ODBC[^] or ADO.NET[^] driver.

Then you need to follow the instructions that come with the driver to connect. Typically something like:
var conn = new MySqlConnection("my connection string");


您可能需要提供者:

http:// dev。 mysql.com/downloads/connector/net/ [ ^ ]
You might want the provider:
http://dev.mysql.com/downloads/connector/net/[^]


Google [ ^ 。首先尝试其中一些。
There are many solutions suggested by Google[^]. Try some of them first.


这篇关于如何连接到MySql数据库.Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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