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
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog