Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Procedure or function expects parameter which was not supplied

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?

like image 629
eftpotrm Avatar asked Apr 07 '10 23:04

eftpotrm


1 Answers

Change the command type to Procedure

like image 77
Remus Rusanu Avatar answered Oct 19 '22 00:10

Remus Rusanu