C# winforms login cant connecr to mysql (error 40) /login doesnt work

Hello i have created simple login form with mysql db from internet example.internet example I use xampp for localhost mysql hosting. But every time when i try use login form i get this message. error message It seems it cant connect to db but i cant find out why. I think my connection string is fine but run out of ideas and its possible code is just bad. I tried: using different sql hosting, setting permissions in phpmyadmin, creating new user for connection to db, using different connection string.

private void btnLogin_Click(object sender, EventArgs e)
    {
        String result = "";
        try
        {
            con = new SqlConnection(@"Data source=localhost;Initial Catalog=users;User ID=root;Password=test.test;Integrated Security=True");
            cmd = new SqlCommand("select * from tblLogininfo where UserId=@uid and Password=@password", con);
            con.Open();
            cmd.Parameters.AddWithValue("@uid", txtUserId.Text.ToString());
            cmd.Parameters.AddWithValue("@password", txtPassword.Text.ToString());
            reader = cmd.ExecuteReader();
            if (reader.Read())
            {
                if (reader["Password"].ToString().Equals(txtPassword.Text.ToString(), StringComparison.InvariantCulture))
                {
                    UserInfo.empid = reader["EmpId"].ToString();
                    UserInfo.userid = reader["UserId"].ToString();
                    UserInfo.role = reader["UserRole"].ToString();
                    result = "1";
                }
                else
                    result = "Invalid credentials";
            }
            else
                result = "Connection failed";

            reader.Close();
            cmd.Dispose();
            con.Close();

        }
        catch (Exception ex)
        {
            result = ex.Message.ToString();
        }

        if (result == "1")
        {
            Program.openDashboard = true;
            this.Close();
        }
        else
            MessageBox.Show(result);
    }

Answer

According with the varius comments, you need to include the reference to MySQL. So right click in “references”, in solution explorer tab -> manage NuGet packages -> browse tab -> search for “mysql” -> install MySQL.Data.

After the download, add using MySql.Data.MySqlClient;

At this point substitutes all the occurrences of SQL . . . with MySQL . . . .