I saw many questions on stack overflow, non of them touched my own problem
procedure or function expects parameter which was not supplied
I just found that I can set default values for the parameter in the stored procedure:
ALTER proc [dbo].[spAddCustomer]
@cuName varchar(50)=null,
@cuAddress varchar(50)=null,
@cuMobile varchar(50)= null,
@cuImage image= null,
@cityId int= null,
@exist int output
And this solved my problem! This is helpful specifically with null images from the PictureBox, since I have a helper method that checks for empty strings.
You need to check your input for null and use DBNull.Value
when you creating the parameters. If you pass just null
as a parameter - ADO.Net will ignore that.
EDIT:
You can add that check into your custom method DataAccessLayer.CreateParameter()