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?
Change the command type to Procedure
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With