将C#连接到MySQL数据库时出现SocketException [英] SocketException while connecting C# to MySQL Database

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

问题描述

异常原因:系统在尝试使用指针参数时检测到无效指针地址



我的代码:

Reason for the exception:The system detected an invalid pointer address in attempting to use a pointer argument in a call

My Code:

String connection_string = "Server=localhost;Database=test;Uid=root;Pwd=password;";
MySqlConnection con = new MySqlConnection(connection_string);
MySqlCommand cmd=con.CreateCommand();
con.Open();            //Exception at this line





连接字符串有问题吗?我已经从这里提到了



Is there any problem in connection string? I have referred from here

推荐答案

尝试将项目设置为编译在x86而不是AnyCPU模式。
Try setting your project to compile in x86 instead of the AnyCPU mode.


这篇关于将C#连接到MySQL数据库时出现SocketException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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