Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Folks,

I am facing a problem with ExecuteNonQuery method in Oracle.
C#
oraConnection = new Oracle.DataAccess.Client.OracleConnection(_connectionString);

Oracle.DataAccess.Client.OracleCommand cmd= new Oracle.DataAccess.Client.OracleCommand("Update tableA set Name='Anand' where Id=25005', oraConnection);

      orda.UpdateCommand = cmd;
      cmd.CommandType = CommandType.Text;
      cmd.CommandTimeout = 0;
      oraConnection.Open();
      rowAfected = cmd.ExecuteNonQuery(); 


On ExecuteNonQuery my application got hanged looks like operation is still in progress.

Any help is appreciated.
Posted
Updated 11-Jun-14 1:29am
v2
Comments
[no name] 11-Jun-14 7:30am    
Try setting your time out to something other than waiting infinitely. Or get rid of it altogether.
CHill60 11-Jun-14 7:34am    
Is that your code exactly as it appears? Because you are missing the closing quotes on your command string
[no name] 11-Jun-14 7:42am    
You should go back to "Hawkeye" ;-) Good catch.
ZurdoDev 11-Jun-14 7:41am    
As mentioned, your code as posted is incorrect syntactically. However, I would suggest running the statement directly in Oracle to see what happens. Also, a CommandTimeout of 0 is dangerous. You may need to set it to 5 minutes or something high but I would not set it to 0.

Updates depend on indexing and how long it takes Oracle to find the record.
vickyanand25005 11-Jun-14 8:12am    
I have tried the same script in oracle it is working fine and If i set timeout then query execution stops after that time with error execution canceled by User.My connection is also getting close it just a code snippet where the problem is.

1 solution

You are missing a close directive:
oraConnection.Open();
rowAfected = cmd.ExecuteNonQuery(); 
oraConnection.Close();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900