chào mọi người, hiện tại mình tìm hiểu kết nối từ c# đến database online, host mình dùng là stablehost
báo lổi nhu sau:using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using MySql.Data.MySqlClient;
private void button1_Click(object sender, EventArgs e)
{
string ConnectionString = "Server=IP_Server;Port=3306;Database=ten_database; Username=TenUserName;Password=Password_database";
MySqlConnection conn = new MySqlConnection(ConnectionString);
try
{
conn.Open();
MessageBox.Show("ket noi thanh cong");
}
catch (Exception ex)
{
MessageBox.Show("ket noi that bai: \n\n" + ex.ToString());
}
ket noi that bai:
MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.Driver.Open()
at MySql.Data.MySqlClient.Driver.Create(MySqlConnecti onStringBuilder settings)
at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledCo nnection()
at MySql.Data.MySqlClient.MySqlPool.GetPooledConnecti on()
at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
at MySql.Data.MySqlClient.MySqlPool.GetConnection()
at MySql.Data.MySqlClient.MySqlConnection.Open()
Remote MySQL: e đã chọn cho tất cả các IP đều có thể truy cập được
mở port 3306 trên máy tính của e luôn
Server Information: e click vào chổ nầy để lấy cái IP Server từ cpanel stablehost
các anh chị nào đã từng kết nối từ c# đến database online rồi cho e xin ít kinh nghiệm để e test thử, hoặc cho e lời khuyên e cần phải làm gì để connect được database online dùng stable host ạ, thanks mọi người đã xem qua.
cảm ơn!
Những câu hỏi như vậy, bạn nên hỏi trức tiến với host provider. Trước khi bạn muốn sử dụng Direct Access, bạn nên dùng Visual STudio Management connects qua thử xem work ko ?
VNFox là ai?www.vnfox.com
Cafe cùng VNFox @ fb.me/vnfoxcafe