查看: 1021|回复: 3
|
unable to connect to any mysql hosts
[复制链接]
|
|
try
{
string myConnection = @"server=localhost,port =3306; database=lipsy2; username=root;password=7483876;";
MySqlConnection myConn = new MySqlConnection(myConnection);
MySqlDataAdapter myDataAdapter = new MySqlDataAdapter();
myDataAdapter.SelectCommand = new MySqlCommand("select * lipsy2.customer;", myConn);
MySqlCommandBuilder cb = new MySqlCommandBuilder(myDataAdapter);
myConn.Open();
// DataSet ds = new DataSet();
//.Show("Connected");
txtMsg.Text = "Connected";
myConn.Close();
}
catch (Exception ex)
{
txtMsg.Text = ex.Message;
//MessageBox.Show(ex.Message);
}
|
|
|
|
|
|
|
|

楼主 |
发表于 28-10-2013 02:17 PM
|
显示全部楼层
什么问题? 没error. 就是Connect 不到。 |
|
|
|
|
|
|
|
发表于 29-10-2013 09:44 AM
|
显示全部楼层
你确定没error?
你用catch了然后将error assign 到 txtMsg.Text里 ,所以如果有error就会出现在您的textbox里出现(Unable to connect to any...)。
或者你干脆直接拿到try catch,比较好debug |
|
|
|
|
|
|
|
发表于 4-11-2013 03:21 PM
|
显示全部楼层
|
|
|
|
|
|
| |
本周最热论坛帖子
|