2021年4月8日 星期四

ASP.NET C# MariaDB 連結字串

web.config  加入下面內容

<connectionStrings>

<add name="connect string" connectionString="server=IP;user id=user name;password=Password;Persist Security Info=True;Database=DB name;" providerName="MySql.Data.MySqlClient"/>

</connectionStrings>


程式引用

using MySql.Data.MySqlClient;

........

MySqlConnectionStringBuilder sqlsb = new MySqlConnectionStringBuilder(ConfigurationManager.ConnectionStrings["connect string"].ConnectionString);

MySqlConnection MySqlConnection = new MySqlConnection(sqlsb.ConnectionString);

string sqlStatement = @"select * from test";

MySqlCommand MySqlCommand = new MySqlCommand(sqlStatement);

MySqlCommand.Connection = MySqlConnection;

MySqlConnection.Open();

解決無法連線不需認證的遠端資料匣

最近User要連事務機資料匣,發現無法連線,錯誤訊息如下:  Fix You can’t access this shared folder because your organization’s security policies block unauthenticated 解...