【问题标题】:problems SocketException was unhandled问题 SocketException 未处理
【发布时间】:2016-03-14 19:06:46
【问题描述】:

我在csharp做的工作,在那里我做了一个表格,在数据库中注册了用户,所以当我打开这个表格按钮时,是用来指实际查看数据库中用户的数据,但它是一个确认在SocketException 中,我知道网络错误并且我的代码是正确的,所以我不知道如何解决这个问题,有人可以帮我吗?

namespace exercicio_sharp_banco
{
    class banco_clientes
    {
        MySqlConnection conexao;
        MySqlCommand comando;
        MySqlDataAdapter captura;
        DataTable tabClientes;

        public void conectaBanco()
        {
            conexao = new MySqlConnection("server=localhost;user id=root;database=t3it1_dbdados");
            conexao.Open();//here and the warning
        }

        public DataTable mostraRegistros()
        {
            captura = new MySqlDataAdapter(comando);
            tabClientes = new DataTable();

            captura.Fill(tabClientes);
            return(tabClientes);
        }

        public void fechaBanco()
        {
            conexao.Close();
        }

        public void Consulta()
        {
            comando = new MySqlCommand("select * from clientes",conexao);
        }

        public void ConsultaPoa()
        {
            comando = new MySqlCommand("select * from clientes where cidade='Porto Alegre'",conexao);
        }

        public void ConsultaDinamica(string textoConsulta)
        {
            comando = new MySqlCommand("select * from clientes where cidade like '%" +textoConsulta +"%' ",conexao);
        }
    }
}

【问题讨论】:

  • 您确定您的 MySQL 实例正在运行和配置正确吗?

标签: c# socketexception


【解决方案1】:

这可能有几个原因:

  • 您的防火墙阻止了您的 MySQL 服务器
  • 您的 MySQL 服务器没有运行
  • 您的 MySQL-Server 配置不正确

【讨论】:

    猜你喜欢
    • 2019-11-27
    • 2021-04-12
    • 1970-01-01
    • 2010-09-29
    • 1970-01-01
    • 1970-01-01
    • 2018-04-23
    • 2014-08-27
    • 1970-01-01
    相关资源
    最近更新 更多