C#项目与Mysql的连接 [英] C# project connection to Mysql

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

问题描述


我想将Windows c#项目连接到MySql.因此,要执行此操作是必须安装"mysql连接器",还是有其他替代解决方案?

Hi,
I want to connect my windows c# project to MySql. So to do this is it mandatory to install "mysql connector" or there is any alternative solution?

推荐答案

好了,您下面确实需要某种数据库驱动程序.而且,如果您不想要MySQL连接器,那么您将需要与之等效的东西.

我记不清楚了,但是在过去,我相信我使用了C驱动程序(可以静态链接).因此,如果分发是您的问题,请编写一个静态链接到所需驱动程序库的C DLL,然后可以从C#代码中P/调用它. (我的内存不再是以前的样子,所以我不确定是为MySQL还是为PostgreSQL写的).
Well you do need some kind of database driver underneath. And if you don''t want MySQL connector, then you''d need something equivalent to that.

I don''t remember clearly, but in the old days, I believe I have used C drivers (which can be statically linked). So if distribution is your problem, write a C DLL that statically links to the required driver libs, and then you can P/Invoke this from your C# code. (my memory is not what it used to be, so I am not sure if I wrote this for MySQL or for PostgreSQL)


是的,您将需要MySQL连接器.在此处查看详细信息 http://bitdaddys.com/MySQL-ConnectorNet.html [使用ObjectDataSources的MySQL 5 C#示例代码 [
Yes, you will need the MySQL connector. See detail here http://bitdaddys.com/MySQL-ConnectorNet.html[^]

and sample project @ MySQL 5 C# sample code using ObjectDataSources[^]



您可以从此链接下载mysql.data.dll
-------------------------------------------------- --------
http://dev.mysql.com/downloads/mirror.php?id=393489#mirrors

http://dev.mysql.com/downloads/connector/net/1.0.html#downloads
-------------------------------------------------- --------
并将其放在bin文件夹中.
使用此命名空间
----------------------------
使用MySql.Data.MySqlClient;
----------------------------
您可以使用类似于ms sql的mysql.
如果要使用mysql配置sqldatasource,则应安装
mysql连接器.

问候,
Vishak
Hi,
You can download the the mysql.data.dll from this links
----------------------------------------------------------
http://dev.mysql.com/downloads/mirror.php?id=393489#mirrors

http://dev.mysql.com/downloads/connector/net/1.0.html#downloads
----------------------------------------------------------
and put it in the bin folder.
Using this namespace
----------------------------
using MySql.Data.MySqlClient;
----------------------------
u can use mysql similar to ms sql.
If u want to configure sqldatasource with mysql u should install
mysql connector.

Regards,
vishak


这篇关于C#项目与Mysql的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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