ORA-01036: illegal variable name/number when running query through C#

前端 未结 10 1647
执念已碎
执念已碎 2020-12-06 17:20

I am trying to use ALTER USER query for Oracle database using OracleCommand in C# in the following code. It creates the query if the values for Username and pas

相关标签:
10条回答
  • 2020-12-06 18:09

    I have faced same problem ... For the problem is like this, I am calling the PRC inside cpp program and my PRC taking 4 arguments but while calling I used only 1 arguments so this error came for me.

    Begin Example_PRC(:1); End; // this cause the problem 
    Begin Example_PRC(:1,:2,:3,:4); End; // this is the solution
    
    0 讨论(0)
  • 2020-12-06 18:11

    I just spent several days checking parameters because I have to pass 60 to a stored procedure. It turns out that the one of the variable names (which I load into a list and pass to the Oracle Write method I created) had a space in the name at the end. When comparing to the variables in the stored procedure they were the same, but in the editor I used to compare them, I didnt notice the extra space. Drove me crazy for the last 4 days trying everything I could find, and changing even the .net Oracle driver. Just wanted to throw that out here so it can help someone else. We tend to concentrate on the characters and ignore the spaces. . .

    0 讨论(0)
  • 2020-12-06 18:11

    You defined one oracleCommand but used it in 'for'. it means you are adding parameter with the same name to one OracleCommand. you should use cmd.Parameters.clear() to refresh your parameters.

    for(int i=0;i<usersList.Count;i++)
            {
                if (!(selectedUsersArray[i].Equals("")) && !passwordArray[i].Equals(""))
                {
                    cmd.Parameters.clear();//Add this line
                    OracleParameter userName = new OracleParameter();
                    userName.ParameterName = "user";
                    userName.Value = selectedUsersArray[i];
    
                    OracleParameter passwd = new OracleParameter();
                    passwd.ParameterName = "password";
                    passwd.Value = passwordArray[i];
    
                    cmd.Parameters.Add(userName);
                    cmd.Parameters.Add(passwd);
    
                    cmd.Prepare();
                    cmd.ExecuteNonQuery();                   
    
    
                }
            } 
    
    0 讨论(0)
  • 2020-12-06 18:11

    This error happens when you are also missing cmd.CommandType = System.Data.CommandType.StoredProcedure;

    0 讨论(0)
提交回复
热议问题