Cant connect to a sql server using c#

Copper Contributor

Cant connect to a sql server using c#, it is just giving me an error "SocketException: The server broke off connection"

Code:

string serverName = "ropchocale.database.windows.net";
            string userName = "Ropchocale";
            string dbName = "dbo.test";
            string port = "1433";
            string password = "Gr21041244";
            string connStr = "server=" + serverName +
                ";user id=" + userName +
                ";database=" + dbName +
                ";port=" + port +
                ";password=" + password + ";";
            MySqlConnection conn = new MySqlConnection(connStr);
            conn.Open();
            string sql = "SELECT password FROM 1st where id = 1";
            MySqlScript script = new MySqlScript(conn, sql);
            int count = script.Execute();

There is random server name and etc, but in my code there right. What the problem can be?

0 Replies