C# walin karapu application ekaka database eka thiyenne cpanel eke mata one mage application eka cpanel eke database ekath ekka connect karanna man mage connection eke code eka thama me
Code:
private string databaseName = string.Empty;
public string DatabaseName
{
get { return databaseName; }
set { databaseName = value; }
}
public string Password { get; set; }
private MySqlConnection connection = null;
public MySqlConnection Connection
{
get { return connection; }
}
private static DbConnection _instance = null;
public static DbConnection Instance()
{
if (_instance == null)
_instance = new DbConnection();
return _instance;
}
public bool IsConnect()
{
if (Connection == null)
{
if (String.IsNullOrEmpty(databaseName))
return false;
string connstring = string.Format("Server=xx.xxx.xxx.xxx;database={0}; UID=xxxxx; password=xxxxxx;SslMode = none", databaseName);
connection = new MySqlConnection(connstring);
connection.Open();
}
return true;
}
public void Close()
{
connection.Close();
}
}
but mata me error eka enawa
Code:
MySql.Data.MySqlClient.MySqlException was unhandled
Code=0
ErrorCode=-2147467259
HResult=-2147467259
Message=Unable to connect to any of the specified MySQL hosts.
Number=1042
Source=MySql.Data
StackTrace:
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.Driver.Open()
at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
at MySql.Data.MySqlClient.MySqlPool.GetConnection()
at MySql.Data.MySqlClient.MySqlConnection.Open()
at POS_Jayamal.DbConnection.IsConnect() in C:\Users\123456\Documents\POS_Jayamal\POS_Jayamal\DBConnection.cs:line 49
at POS_Jayamal.StockDetailsForm.load_items() in C:\Users\123456\Documents\POS_Jayamal\POS_Jayamal\StockDetailsForm.cs:line 23
at POS_Jayamal.StockDetailsForm.StockDetailsForm_Load(Object sender, EventArgs e) in C:\Users\123456\Documents\POS_Jayamal\POS_Jayamal\StockDetailsForm.cs:line 16
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
InnerException:
Code=0
ErrorCode=-2147467259
HResult=-2147467259
Message=Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Number=0
Source=MySql.Data
StackTrace:
at MySql.Data.Common.StreamCreator.GetTcpStream(MySqlConnectionStringBuilder settings)
at MySql.Data.Common.StreamCreator.GetStream(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.NativeDriver.Open()
InnerException:
Access Host ekata PC eke IP ekath deela thiyenne bn




