gpt4 book ai didi

c# - 通过 C#/Visual Studio 2012 连接到外部 mysql 数据库

转载 作者:可可西里 更新时间:2023-11-01 08:49:34 26 4
gpt4 key购买 nike

每当我尝试在我的本地主机上执行带有插入的 SQL 查询时,它都会工作,使用简单的 C# 代码和 Visual Studio 中的 Mysql.Data 引用。但是当我尝试连接到网络服务器上我自己的数据库时,它给了我一个异常(exception):

A first chance exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.

我的网络服务器是否阻止了来自 visual studio/c# 的外部请求?如何打开服务器以允许这些请求?

谢谢。

最佳答案

我用 c# 开发了一个应用程序,因为我使用 MySQL 数据库作为存储在 bigrock.com 的后端。在您的应用程序中,它们将是连接字符串中的简单错误。并关闭防火墙和防病毒设置。

这是 MySQL 数据库连接字符串的正确格式:-

string connectionString = "Server=Your_Server_Name;Uid=Your_User_Name;Database=Your_Database_Name;port=Your_Port_No;Pwd=Your_Password;Allow Zero Datetime=true";

关于c# - 通过 C#/Visual Studio 2012 连接到外部 mysql 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17594330/

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