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();
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.
– Otto
have any suggestions of what to put in the catch?
– Diego Filipe Pedro Santos
something like this could help catch (Exception e) { Console.Writeline("An error occurred: '{0}'", e); }
– Otto
Regarding IIS yes it has permission and uses the necessary libraries.
– Diego Filipe Pedro Santos
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.
– carlosfigueira
I have enabled but it was not very enlightening.
– Diego Filipe Pedro Santos