0

I want do the folowing request :

SELECT nom_projet, version_projet, version_build FROM analyses WHERE nom_projet=:Variable1 and version_projet=:Variable2 and version_build=:Variable3";

I dont understand why it doesn't work because i have done the same code for a request INSERT and this one works perfectly.

Code C#

public Boolean VerifierVersionDejaPresnte(ParseurXML.DonneesGblobale donneGlobale)
{
OracleCommand cmd = new OracleCommand();
cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "SELECT nom_projet, version_projet, version_build FROM  analyses WHERE nom_projet=:Variable1 and version_projet=:Variable2 and version_build=:Variable3" 
cmd.CommandType = CommandType.Text;
cmd.Parameters.Add(new OracleParameter("Variable1",donneGblobale._nom));
cmd.Parameters.Add(new OracleParameter("Variable2",donneGblobale._version));
cmd.Parameters.Add(new OracleParameter("Variable3",donneGblobale._build));

OracleDataReader reader = cmd.ExecuteNonQuery();
if(reader.HasRows)
  return true;
return false;
}
2
  • 1
    I assume that the missing colon at version_build=Variable3 is just a typo? Commented Jun 9, 2016 at 9:04
  • Yes sorry, i modify it Commented Jun 9, 2016 at 9:06

1 Answer 1

2

You are calling ExecuteNonQuery while you should call ExecuteReader.

ExecuteNonQuery is used for Insert,Update and Delete commands.

OracleDataReader reader = cmd.ExecuteReader();
Sign up to request clarification or add additional context in comments.

6 Comments

when the program tries to execute cmd.ExecuteReader () I have an exception, do you have any ideas ?
What is exception ?
unfortunately I'm not sure this execption is going to help us much: external component has thrown an exception
Can u share the exception details
I'm sorry, it was my mistake I did a error in the code ... Your answer works perfectly.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.