gpt4 book ai didi

c# - 在 openshift 上连接 mysql 服务器时出错

转载 作者:行者123 更新时间:2023-11-29 20:54:52 25 4
gpt4 key购买 nike

我正在尝试连接到在 openshift 上运行的 mysql 数据库。我用的电脑是win 10。下面是我想要做的 C# 代码片段。服务器地址、密码和用户名已被清空。

  string connStr = @"Server=xxxxxxx.rhcloud.com:3306;Database=hurnhusms;Uid=XXX;password=XXX;";
SqlConnection conn = new SqlConnection(connStr);
try
{
Console.WriteLine("Connecting to MySQL...");
conn.Open();
Console.WriteLine("Connection successfull !");
conn.Close();
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine("error => " + ex.ToString());
}
Console.ReadLine();

当我运行应用程序时,我得到的只是:

System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. i have also ran rhc port-forward , i have also pinged the mysql port on the site and it is open.

如有任何帮助,我们将不胜感激。

最佳答案

好吧,我发现我需要执行 rhc port-forward,然后保持该窗口打开(而不是终止该命令)。我没有意识到窗口需要保持打开状态。

关于c# - 在 openshift 上连接 mysql 服务器时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37716092/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com