dongshanni1611 2015-01-31 07:46
浏览 200

将桌面c#应用程序连接到联机mySql数据库

I have a windows form application in C# and sometimes I want to push some data table from this application to an online mySql server which is hosting all data for my website in PHP. To do that I've installed :

1- MySql for visual studio version 1.2.3

2- MySql Connector.Net 6.9

Also, I have enabled Remote MySql on the server so I can make the connection. I used the '%' wildcard for the meantime because my IP address is dynamic.

my basic c# connection code is as below :

MySql.Data.MySqlClient.MySqlConnection conn;
string myConnectionString;

myConnectionString = "Server=*******;Database=*******;Uid=******;Pwd=********;";

        try
        {
            conn = new MySql.Data.MySqlClient.MySqlConnection();
            conn.ConnectionString = myConnectionString;
            conn.Open();
            MessageBox.Show("connected successfully..");
        }
        catch (MySql.Data.MySqlClient.MySqlException ex)
        {
            MessageBox.Show(ex.Message);

        }

Unfortunately, every time I run this code I am getting an error which says "Unable to connect to any of the specified MySQL hosts". I don't' know where the problem is. Is it something on the UNIX server which blocks the connections or some other thing which I need to do. I am also new to the CPanel interface and how to deal with it.

I appreciate all the help provided. Many Thanks.

  • 写回答

2条回答

  • dongzhimin2231 2015-01-31 07:50
    关注
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料