【发布时间】:2015-06-13 05:12:49
【问题描述】:
我目前正在尝试用 c# 做一个 mysql 工具,用于从我的数据库中导出数据。
我对 mysql.Connectionstring 进行了硬编码:
private MySqlConnection _conn;
mycon = "server=127.0.0.1;uid=tools;pwd=tools;database=t_data;";
_conn.ConnectionString = mycon;
这完全没有问题。但正如你所知,你希望它是可编辑的。所以我在我的表单中创建了 3 个文本框。添加了一个类。
当我点击导出时,我将文本框值分配给我的班级
StringExporter.user.ip = textBox1.Text;
StringExporter.user.usr = textBox2.Text;
StringExporter.user.pwd = textBox3.Text;
StringExporter.user.db = textBox4.Text;
这是我的课
public static class user
{
public static string ip;
public static string usr;
public static string pwd;
public static string db;
}
但是每次我想导出时,我都会收到一个 Mysql 错误,即没有选择数据库,我不明白为什么。我输出了所有的字符串,它们都很好。
如果有人可以帮助我,那就太好了:)
【问题讨论】:
-
您能否发布您用于导出数据的整个代码?
标签: c# mysql connection-string