Hi all
I am trying to use a stored procedure to insert an image into a database table, and I am getting the following error:
The structure of my table (StaffImages) is:
Identification int (PK) (Identity Specification = yes)
Staff int (allow null)
Picture image (allow null)
ImageType nvarchar (400) (allow null)
My stored procedure is:
My code for executing the stored procedure is:
Can anyone suggest what my problem is, I can successfully insert the image if I hard code the sql cmd into my vb.net code, however I want to employ the stored procedure, as it would give my greater flexibility in the long term.
Mike55.
I am trying to use a stored procedure to insert an image into a database table, and I am getting the following error:
"Incorrect syntax near procInsertImage.
The structure of my table (StaffImages) is:
Identification int (PK) (Identity Specification = yes)
Staff int (allow null)
Picture image (allow null)
ImageType nvarchar (400) (allow null)
My stored procedure is:
Code:
ALTER PROCEDURE [dbo].[procInsertImage]
-- Add the parameters for the stored procedure here
@Account nvarchar (50),
@Picture image,
@ImageType nvarchar (400)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
DECLARE @SID int
-- Insert statements for procedure here
SELECT @SID = Staff.Identification
FROM Accounts INNER JOIN
Credentials ON Accounts.identification = Credentials.Account INNER JOIN
Staff ON Credentials.StaffMember = Staff.Identification
WHERE Accounts.Account = @Account
INSERT INTO StaffImages (Staff, Picture, ImageType)
VALUES (@SID, @Picture, @ImageType)
END
My code for executing the stored procedure is:
Code:
cmdSQL = New SqlCommand("procInsertImage", connSQL)
With cmdSQL
.Parameters.Add(New SqlParameter("@Account", SqlDbType.NVarChar, 50))
.Parameters("@Account").Direction = ParameterDirection.Input
.Parameters("@Account").Value = account
.Parameters.Add(New SqlParameter("@Picture", SqlDbType.Image))
.Parameters("@Picture").Direction = ParameterDirection.Input
.Parameters("@Picture").Value = image
.Parameters.Add(New SqlParameter("@ImageType", SqlDbType.NVarChar, 400))
.Parameters("@ImageType").Direction = ParameterDirection.Input
.Parameters("@ImageType").Value = imageType
End With
cmdSQL.ExecuteNonQuery()
Can anyone suggest what my problem is, I can successfully insert the image if I hard code the sql cmd into my vb.net code, however I want to employ the stored procedure, as it would give my greater flexibility in the long term.
Mike55.