<pre>I have this error during update of the customer table:
Procedure or function 'Update_Customer' expects parameter '@CustomerPhoto', which was not supplied.
Stored procedure code :<pre>
ALTER procedure [dbo].[Update_Customer]
@CustomerID int output,
@CustomerName nvarchar (50),
@CustomerPhoto image,
@CustomerEmail nvarchar(Max),
@CustomerPhone1 nvarchar(12),
@CustomerPhone2 nvarchar(12),
@CustomerAddress nvarchar(Max),
@CustomerFax nvarchar(12),
@CustomerStatus bit,
@CountryID int,
@CityID int,
@Notes nvarchar (Max),
@ModifiedBy nvarchar (30)
AS
BEGIN
UPDATE CustomersTbl
SET CustomerID = @CustomerID,
CustomerName = @CustomerName,
CustomerPhoto = @CustomerPhoto,
CustomerEmail = @CustomerEmail,
CustomerPhone1 = @CustomerPhone1,
CustomerPhone2 = @CustomerPhone2,
CustomerAddress = @CustomerAddress,
CustomerFax = @CustomerFax,
CustomerStatus = @CustomerStatus,
CountryID = @CountryID,
CityID = @CityID,
Notes = @Notes,
ModifiedDate = GETDATE(),
ModifiedBy = @ModifiedBy
WHERE
CustomerID = @CustomerID
END
Data layer class code :
Friend Function Update_Customer(ByVal CustomerID As String, ByVal CustomerName As String, ByVal CustomerEmail As String, ByVal CustomerPhone1 As String, ByVal CustomerPhone2 As String, ByVal CustomerAddress As String, ByVal CustomerFax As String, ByVal CustomerStatus As Boolean, ByVal CountryID As Integer, ByVal CityID As Integer, ByVal Notes As String, ByVal ModifiedBy As String) As String
Dim retval As String
Dim cmd As New SqlCommand("Update_Customer")
cmd.Parameters.AddWithValue("@CustomerID", CustomerID)
cmd.Parameters.AddWithValue("@CustomerName", CustomerName)
cmd.Parameters.AddWithValue("@CustomerPhoto", SqlDbType.Image).Value = photo
cmd.Parameters.AddWithValue("@CustomerEmail", CustomerEmail)
cmd.Parameters.AddWithValue("@CustomerPhone1", CustomerPhone1)
cmd.Parameters.AddWithValue("@CustomerPhone2", CustomerPhone2)
cmd.Parameters.AddWithValue("@CustomerAddress", CustomerAddress)
cmd.Parameters.AddWithValue("@CustomerFax", CustomerFax)
cmd.Parameters.AddWithValue("@CustomerStatus", CustomerStatus)
cmd.Parameters.AddWithValue("@CountryID", CountryID)
cmd.Parameters.AddWithValue("@CityID", CityID)
cmd.Parameters.AddWithValue("@Notes", Notes)
cmd.Parameters.AddWithValue("@ModifiedBy", ModifiedBy)
retval = dm.executeNonQuery(cmd)
Return retval
End Function
Business layer class code :
Public Function Update_Customer_WithOutPic(ByVal CustomerID As String, ByVal CustomerName As String, ByVal CustomerEmail As String, ByVal CustomerPhone1 As String, ByVal CustomerPhone2 As String, ByVal CustomerAddress As String, ByVal CustomerFax As String, ByVal CustomerStatus As Boolean, ByVal CountryID As Integer, ByVal CityID As Integer, ByVal Notes As String, ByVal ModifiedBy As String) As String
Dim retval As String
retval = p.Update_Customer_WithOutPic(CustomerID, CustomerName, CustomerEmail, CustomerPhone1, CustomerPhone2, CustomerAddress, CustomerFax, CustomerStatus, CountryID, CityID, Notes, ModifiedBy)
Return retval
End Function
Update button code :
Dim retval As String = p.Update_Customer(txtCustomerCode.Text, txtCustomerName.Text, txtCustomerEmail.Text, txtCustomerPhone1.Text, txtCustomerPhone2.Text, txtCustomerAddress.Text, txtCustomerFax.Text, CheckBox2.Checked, ComboCustomerCountry.SelectedValue, ComboCustomerCity.SelectedValue, txtCustomernote.Text, FrmMain.LblUserID.Text)
Module :
Public Function GetPhoto(ByVal filePath As String) As Byte()
Dim stream As FileStream = New FileStream(filePath, FileMode.Open, FileAccess.Read)
Dim reader As BinaryReader = New BinaryReader(stream)
Dim photo() As Byte = reader.ReadBytes(stream.Length)
reader.Close()
stream.Close()
Return photo
End Function
Public Function byteArrayToImage(ByVal byt As Byte()) As Image
Dim ms As New System.IO.MemoryStream()
Dim drwimg As Image = Nothing
Try
ms.Write(byt, 0, byt.Length)
drwimg = New Bitmap(ms)
Finally
ms.Close()
End Try
Return drwimg
End Function
What I have tried:
Iam sure that picture box is not empty