0

I have this problem with a query I have, I am using Oracle Commands and Parameters. I have hundreds of other queries in my code, but just this one is failing to execute. It is a very simple update query and it works in SQL Navigator because I tried it.

Within the code, the execute non query method seems like it freezes and i get "Waiting for http:// localhost:8081/MaintainUserProfile.aspx" in my webpage.

I appreciate your help because I've wasted hours on it and I'm clueless at this stage.

Let me know if I should state more information.

The code below (Please note I work with oracle parameters, but in this case I am just using plain strings to debug the problem, the same happens with oracle parameters, it get stuck on execute non query):

string sqlQuery = @"UPDATE schema_name.table_name
                    SET
                       officer_name = '" + fullName + 
                       "', channel_code = " + channelCode +
                       ", male_female_ind = '" + maleFemale + 
                       "', user_status_code = '" + userStatusCode +
                       "', identity_number = '" + idNumber +
                       "', extension_number = " + extensionNumber +
                       " WHERE user_profile_id = " + userProfileID;

 OracleCommand oraCommand2 = new OracleCommand(sqlQuery, db);
 oraCommand2.ExecuteNonQuery();
7
  • @Justing Harvey - I am not getting any error, it fails to execute and remains like it is executing and I end up waiting endlessly. Commented Sep 17, 2012 at 10:39
  • How much data is in that table? I am wondering if it is possible if it is hanging just finding the row to update. Commented Sep 17, 2012 at 10:42
  • @Justing Harvey - This should update a single row, it is updating a user, from a list of around 1,200 users. Commented Sep 17, 2012 at 10:43
  • @Justin Harvey - Having said that, a similar update query in a different page works perfectly, without hanging. This is the funny thing. Commented Sep 17, 2012 at 10:43
  • Are you totally sure it is the SQL that is hanging and not something else in the aspx page request? Commented Sep 17, 2012 at 11:07

2 Answers 2

1

You can try with this code - Based on AddWithValue

oraCommand2.CommandText="UPDATE schema_name.table_name SET
                       officer_name = :fullName , channel_code = :channelCode, 
                       male_female_ind = :male_female_ind, user_status_code = :user_status_code,
                       identity_number = :idNumber, extension_number = :extensionNumber 
                       WHERE user_profile_id = :userProfileID";

oraCommand2.Parameters.AddWithValue(":fullName", fullName);
oraCommand2.Parameters.AddWithValue(":channelCode", channelCode);
oraCommand2.Parameters.AddWithValue(":male_female_ind", male_female_ind );
oraCommand2 .Parameters.AddWithValue(":user_status_code", user_status_code );
oraCommand2 .Parameters.AddWithValue(":identity_number", identity_number );
oraCommand2 .Parameters.AddWithValue(":extension_number", extension_number );
oraCommand2 .Parameters.AddWithValue(":user_profile_id", user_profile_id );

Link : http://msdn.microsoft.com/fr-fr/library/system.data.oracleclient.oracleparametercollection.addwithvalue.aspx

Sign up to request clarification or add additional context in comments.

2 Comments

Yaoub - Are you sure there is an AddWithValue in the Oracle Commands API, I can only see and Add method. This is how I usually work which still doesn't cut it: OracleParameter oraParamater6 = new OracleParameter(":param6", OracleDbType.Varchar2, 10); oraParamater6.Value = idNumber; oraCommand.Parameters.Add(oraParamater6);
Ryan you can read this link : msdn.microsoft.com/fr-fr/library/…
0

Kenneth answered it in this Post, it may be due to an uncommitted operation in SQLDeveloper (or any other uncommitted pending database change).

Comments

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.