0

I am creating website in ASP.NET Core 2.0 and now I need to get data from my mysql database.

Database is located on hosting which use cpanel

In past I have created simple REST API which get some data from that database and it used this config:

server: db5.cpanelhosting.rs
Port: 3306
user: termodom_guest
pw: a1s2d3f4g5h6j7k8

Now problem is when I use code like this:

using (MySqlConnection con = new MySqlConnection("server=217.26.215.19;port=3306;database=termodom_TDMajstor;user=termodom_guest;password=a1s2d3f4g5h6j7k8"))
{
    con.Open();
    using (MySqlCommand cmd = new MySqlCommand("SELECT * FROM KORISNIK", con))
    {
        MySqlDataReader dr = cmd.ExecuteReader();

        if(dr.Read())
        {
            return true;
        }
    }
}

It drops me error

MySql.Data.MySqlClient.MySqlException (0x80004005): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. at MySql.Data.Common.StreamCreator.GetTcpStream(MySqlConnectionStringBuilder settings) at MySql.Data.MySqlClient.NativeDriver.Open().

I have also tried online testing connection but it also cannot connect. What to do?

10
  • Do you see an error? Also, you should remove your real server connection details. Commented Jul 20, 2018 at 10:02
  • I will leave it for now. I get error MySqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Commented Jul 20, 2018 at 10:03
  • Try to connect using MySQL workbench. If that fails, talk to your provider. See also: stackoverflow.com/questions/3475867/… Commented Jul 20, 2018 at 10:05
  • 1
    Are you sure you want to expose your username/password? I'm guessing you are receiving the error on the con.Open(); line, and the server is not responding. Commented Jul 20, 2018 at 10:05
  • @kry it drops on Open() Commented Jul 20, 2018 at 10:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.