0

I am developing an ASP.net application with Oracle database. When I try to insert data into table REGISTER, it throws an exception as below

ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'INSERTREGISTER'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

table REGISTER has USERNAME, PASSWORD, EMAIL as columns

Store procedure INSERTREGISTER is as following

create or replace
PROCEDURE INSERTREGISTER IS

u1 varchar2(20);
p1 varchar2(20);
e1 varchar2(20);

BEGIN

INSERT INTO REGISTER (USERNAME, PASSWORD, EMAIL) VALUES (u1, p1, e1);

END INSERTREGISTER;

my c# code is:

public int Insert(string u1, string p1, string e1)

    {
        try
        {
            OracleCommand cmd = new OracleCommand("INSERTREGISTER", conn);
            cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add(new OracleParameter("u1", OracleType.VarChar)).Value = u1;
        cmd.Parameters.Add(new OracleParameter("p1", OracleType.VarChar)).Value = p1;
        cmd.Parameters.Add(new OracleParameter("e1", OracleType.VarChar)).Value = e1;

            conn.Open();
            cmd.ExecuteNonQuery();

            return cmd.ExecuteNonQuery();

        }

Kindly help me

regards, Arjun

1 Answer 1

1

Change your procedure to

create or replace
PROCEDURE INSERTREGISTER (u1 varchar2,p1 varchar2,e1 varchar2) AS
BEGIN
--your sql statement
END
Sign up to request clarification or add additional context in comments.

5 Comments

no need for the length of varchar2 (20), just: PROCEDURE INSERTREGISTER (u1 varchar2,p1 varchar2,e1 varchar2) AS BEGIN ...
@A.B.Cade: Thank you!!!!!! Errors gone but the data is getting inserted twice in the table.
That's because you're running cmd.ExecuteNonQuery() twice- one as a call and one in the return cmd.ExecuteNonQuery()
@A.B.Cade : what should I add in the return statement?
@ArjunBabu- You can leave it as it is, but then remove the first call: conn.Open(); return cmd.ExecuteNonQuery(); . BTW you do have a conn.close() in a finally scope, right ?

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.