Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
I have created sp in oracle .

SQL
CREATE OR REPLACE PROCEDURE Usp_Login2(
          user_id IN INT,
          user_name  IN VARCHAR2,
          password IN VARCHAR2
)
AS
    --D_USERID INT;
    D_USERNAME VARCHAR2(50);
    D_PASSWORD VARCHAR2(50);
BEGIN
    SELECT UserName, PASSWORD 
        INTO  D_USERNAME, D_PASSWORD
        FROM   MST_USERS 
        WHERE  USERNAME = user_name
        AND   PASSWORD  = password;

END;


asp.net code is below

C#
public UserBO ValidateLogin(string userName, string password)
        {
            UserBO tmpObjUserBO = null;

            try
            {
                tmpObjUserBO = new UserBO();
                Initialize(StoredProcedure.validateLogin);
                //kimsCmd.Parameters.Clear();
                //KimsDB.AddInParameter(kimsCmd, Parameter.UserId, DbType.Int32, userId);
                KimsDB.AddInParameter(kimsCmd, Parameter.UserName, DbType.String, userName);
                KimsDB.AddInParameter(kimsCmd, Parameter.Password, DbType.String, password);
                
                using (IDataReader reader = KimsDB.ExecuteReader(kimsCmd))
                {
                    if (reader.Read())
                    {
                        if (reader["logininfo"] != null)
                        {
                            tmpObjUserBO.LoginSuccess = Convert.ToString(reader["logininfo"]);
                        }
                        if (tmpObjUserBO.LoginSuccess == "Login success")
                        {
                            tmpObjUserBO.ValidationRequired = false;
                            tmpObjUserBO.UserId = ParseIntValue(reader["userid"]);

                            tmpObjUserBO.RoleId = ParseIntValue(reader["RoleId"]);
                        }
                    }
                }
            }
            catch (OracleException)
            {
                throw;
            }
            catch (Exception)
            {
                throw;
            }
            return tmpObjUserBO;
        }
    }
Posted
Updated 27-Aug-13 2:45am
v4
Comments
sureshsankar 27-Aug-13 6:32am    
pls help me friends...
Thanks7872 27-Aug-13 6:35am    
Help with what? Where is the question? Do you think title of this question as appropriate one? Title should be short and descriptive. You have been given enough space to write the question.
[no name] 27-Aug-13 6:40am    
The error message is perfectly clear. What is is that you do not understand? And you commented out the parameter you need.

1 solution

The error is saying that when you called the stored procedure you did not pass in the right number of parameters. Your SP expects 3 parameters and you only passed 2 because you commented out the line which passes in the user_id.

C#
//KimsDB.AddInParameter(kimsCmd, Parameter.UserId, DbType.Int32, userId);


You need to remove user_id as a parameter from your stored procedure or pass it in.
 
Share this answer
 
Comments
sureshsankar 27-Aug-13 23:56pm    
Hi RyanDev,

I have remove User_id in my sp and same error (PLS-00306: wrong number or types of arguments in call to 'USP_LOGIN2)
ZurdoDev 28-Aug-13 7:15am    
Perhaps you should try using the simpler method of .Parameters.AddWithValue("@user_name", userName);

Also, verify that userName and password are not nulls and actually have a value in them.

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