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 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元