Link to home
Start Free TrialLog in
Avatar of sammySeltzer
sammySeltzerFlag for United States of America

asked on

What is wrong with this function?

I have this function which calls a stored procedure the pulls records from the database.

This stored procedure takes one parameter, pid:

    private void getRecs(int pid)
    {
           SqlConnection conn = new SqlConnection(connStr);
        //Dim cmd As New SqlCommand(s, conn) switched to stored proc below
           SqlCommand cmd = new SqlCommand("[uspGetAllRecs]", conn);
        cmd.CommandType = CommandType.StoredProcedure;
        SqlParameter p1 = new SqlParameter("@pid", pid);
        cmd.Parameters.Add(p1);
        conn.Open();
        cmd.ExecuteNonQuery();
        conn.Close();

    }

Open in new window


Then I am trying to call this function on pageload event but it is giving me an error:

        string pid = Session["PID"].ToString();
             getRecs(pid);

This is the error:

Error      1      The best overloaded method match for 'getRecs(int)' has some invalid arguments

Any ideas?
ASKER CERTIFIED SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sammySeltzer

ASKER

Hi HainKurt,

This always for the providing quick solutions to my questions.

As usual, your solution is perfect.

Thanks alot
Awesome!

It worked.

Thank you very much