Procedure or function expects parameter ' which is not supplied

后端 未结 2 1249
闹比i
闹比i 2021-01-29 12:11

hello friends i face one issue for load the data to grid view.

the page load event call the one method like loaddata() inside i write the code this

  usi         


        
相关标签:
2条回答
  • 2021-01-29 12:26

    If you are calling a stored procedure, in addition to the NULL issue someone mentioned above, there is a type mismatch issue. For instance I was getting the "Expects parameter that is not supplied" error, when I was supplying the parameter.

    After pulling my hair out for a while I found that the procedure had an input parameter of nvarchar(50) and I was passing a string that was longer than that. Apparently any kind of mismatch is reported the same as not providing (which in a way I suppose it is).

    So you may want to double check data types and sizes on both ends.

    0 讨论(0)
  • 2021-01-29 12:33

    The following parameters don't have default values in your stored proc:

    @DateEmailed datetime,            
    @DateResponded datetime, 
    

    So you always need to provide those values in the code:

    cmd.Parameters.Add(new SqlParameter("@DateEmailed", SqlDbType.DateTime));
    cmd.Parameters["@DateEmailed"].Value = DateTime.Now; // Provide your value here
    cmd.Parameters.Add(new SqlParameter("@DateResponded", SqlDbType.DateTime));
    cmd.Parameters["@DateResponded"].Value = DateTime.Now; // Provide your value here
    
    0 讨论(0)
提交回复
热议问题