Problems with WCF + Mysql

Asked

Viewed 58 times

1

I want to use this method, locally it works and returns what I want, when I command IIS simply returns me on the last screen shows the error:

Within the Service1.svc.Cs have this method:

 public string envioPessoa()  {

        MySqlConnection conexao = new MySqlConnection("server='mysql.engb.uni5.net'; UId='engb' ;database='engb'; password='*********';");
        MySqlCommand comando = new MySqlCommand("SELECT * FROM usuarios AS r1 JOIN (SELECT CEIL(RAND() * (SELECT MAX(id) FROM usuarios where TIPO = 'receptor' )) AS id) AS r2 WHERE r1.id >= r2.id AND TIPO = 'receptor' ORDER BY r1.id ASC LIMIT 1", conexao);
        DataTable tabela = new DataTable();
        string retorno = "";
        try
        {
            conexao.Open();
            MySqlDataReader  teste = comando.ExecuteReader();


            while(teste.Read())      
            {

                retorno = teste.GetString(2)+";"+
                teste.GetString(3)+""+
                teste.GetString(4)+";"+
                teste.GetString(5)+";"+
                teste.GetString(7)+";"+
                teste.GetString(8);
            }
        }
        catch (Exception e) { 
           Console.WriteLine("An error occurred: '{0}'", e); 
        }
        conexao.Close();

        return retorno; 

    }

On the interface Iservice1.Cs:

    [OperationContract]
    string envioPessoa();

inserir a descrição da imagem aqui

  • Sure you already checked if the machine that has the IIS has access to the database ? ... could not miss it is not a good practice to use the empty catch ... also known as Pattern silenciator.

  • have any suggestions of what to put in the catch?

  • something like this could help catch (Exception e) { Console.Writeline("An error occurred: '{0}'", e); }

  • Regarding IIS yes it has permission and uses the necessary libraries.

  • Enable WCF Races (https://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx). Whenever a WCF server responds with an error, an entry is written to the Traces file indicating why the error happened.

  • I have enabled but it was not very enlightening.

Show 1 more comment

1 answer

0


First thing I did was enable the web.config servicedebug based on this link enable service debug, from there I checked which version of my Mysql.Data was different from the server I installed in it the new version and also added it in the bin folder where the service was published:

<serviceDebug includeExceptionDetailInFaults="true" />

Browser other questions tagged

You are not signed in. Login or sign up in order to post.