从流中读取失败-MySqlException [英] Reading from the stream has failed - MySqlException
本文介绍了从流中读取失败-MySqlException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用以下代码段打开与MySql数据库的连接:
I'm trying to open a connection to a MySql database using the following code piece:
string connectionString = "Server=ip_number;Database=database_name;Uid=uid;Password=password";
MySqlConnection connection;
connection = new MySqlConnection(connectionString);
connection.Open();
这是我得到的例外情况:
And here is the exception I get:
我正在使用最新的mysql连接器(从此处下载).我想念什么?
I'm using the latest mysql connector (downloaded from here). What am I missing?
预先感谢
推荐答案
可以尝试以下方法:
与服务器的连接:
string connectionString= "datasource=localhost;port=3306;username=uid;password=1234"
使用"MySqL方法"来插入/更新/选择...,例如:
Use the "MySqL-Methodes" to INSERT/UPDATE/SELECT... like:
public string pathselectDB = "select *from try.data;";
public string pathinsertDB = "INSERT INTO `try`.`data`";
string constrnig = pathtoDB;
string Query = pathinsertDB +"(`value1`, `value2`) values('"2"','3',');";
MySqlConnection conDataBase = new MySqlConnection(constrnig);
MySqlCommand cmdDataBase = new MySqlCommand(Query, conDataBase);
MySqlDataReader myReader;
这只是一个例子...我希望这可以解决您的问题.
this is just an example... I hope this solved your problem.
您可以在MySql编辑器中设置用户名和密码!如果您需要帮助,请在下面设置一个表扬.
You can set your username and password in the MySql-Editor! if you need help there just set a commend under this.
这篇关于从流中读取失败-MySqlException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文