1
I am like a strange situation, my code works perfectly in my environment. No tablet client does not work... The only difference is that my tablet has the developer option enabled. I created the application for version 3, the client tablet is with version 4.0.3. Follow the code that when I change error occurs: Works in both environments
Button btnTestaConexao = (Button) layout.findViewById(R.id.btnTestarConexao);
btnTestaConexao.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ConsultaProduto produto = new ConsultaProduto();
Boolean conexaoOk = produto.testaConexao(new ParametroConexao(edtBanco.getText().toString(), edtIp.getText().toString(), edtUsuario.getText().toString(), edtSenha.getText().toString(), edtInstancia.getText().toString()), (ConsultaPrecoActivity) getActivity());
if (conexaoOk) {
Toast.makeText(getActivity(), "Conexão estabelecida com sucesso!", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getActivity(), "Falha na conexão", Toast.LENGTH_LONG).show();
}
}
});
When entering the code below within the if(conexãoOk)
only error in the client:
Produto _produto = produto.consultaProdutoEstoque("012162043052", getActivity());
Toast.makeText(getActivity(), "executou consulta...", Toast.LENGTH_LONG).show();
if (_produto != null) {
Toast.makeText(getActivity(), "Produto: " + _produto.getDescricao(), Toast.LENGTH_LONG).show();
}
Any suggestions?
What is the error? Put the error that appears in logcat.
– Jorge B.
Jorge, thank you for answering. In my environment not of error and in the customer the application simply aborts. I’m starting on Android, will I have some command that only works when the developer option is enabled?
– Seixas
That doesn’t seem to happen. It must be something else...
– Jorge B.
Pretty sure the
produto
must be null. Either this or another variable.– Jorge B.
Check if you have the same content in the database.
– Jorge B.
Without having the error log becomes complicated to know what is going on...
– Jorge B.
Really, I agree with you, without the log becomes difficult. The data is ok, the product exists. What is strange that without the query, running only the connection test works, when I put the query nor the connection test runs. I say this because I included a Toast in the first line of the click method and it is not displaying the message.
– Seixas
So the problem has to be on those lines.
– Jorge B.
It seems to me that some checking is being done before executing the code itself, like a parse of the code. It is logical what I said?
– Seixas
Make an if(product!=null) and put those lines in.
– Jorge B.
I will make this test, return with the result. Thank you.
– Seixas
Jorge, I included all the code in the if you suggested. By clicking the button, if I can connect, the tablet displayed the message that application stopped and aborts, nor displays a Toast that included in the first line of the method. If there is an error in the connection the application correctly informs the connection failure. It must be some detail that I am not able to identify.
– Seixas
I think I’m in the way, I’ve included a Try. .catch... I’m going to do some more tests and return.
– Seixas
Good luck friend :)
– Jorge B.
Jorge, thank you so much for your help. The problem was in query syntax, had a column in select with IIF(PRO_VALOR> 0,PRO_VALOR,PRE_PRECO2) the prices, after replacing with 0 (zero) worked. I’m using the jtds drive to access the sql server, I know it’s not a good practice to directly access the bank. But for this application I had to use this type of connection instead of webservice. When I used Try.. catch I was able to see the messages. The IIF function only exists from the 2012 version of Sql server, the client is using the 2008 version.
– Seixas
Seixas glad you solved the problems :)
– Jorge B.