Procedure or function expects parameter which was not supplied

Posted by eftpotrm on Stack Overflow See other posts from Stack Overflow or by eftpotrm
Published on 2010-04-07T23:32:04Z Indexed on 2010/04/07 23:43 UTC
Read the original article Hit count: 331

Filed under:
|
|
|

Driving me mad on a personal project; I know I've done this before but elsewhere and don't have the code. As far as I can see, I'm setting the parameter, I'm setting its value, the connection is open, yet when I try to fill the dataset I get the error 'Procedure or function expects parameter "@test" which was not supplied'.

(This is obviously a simplified test! Same error on this or the real, rather longer code though.)

C#:

SqlCommand l_oCmd;
DataSet l_oPage = new DataSet();

l_oCmd = new SqlCommand("usp_test", g_oConn);
l_oCmd.Parameters.Add(new SqlParameter("@test", SqlDbType.NVarChar));
l_oCmd.Parameters[0].Value = "hello world";

SqlDataAdapter da = new SqlDataAdapter(l_oCmd);
da.Fill(l_oPage);

SQL:

create procedure usp_test
(
    @test nvarchar(1000)
)
as
select @test

What have I missed?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about sql