Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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:

"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:

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:

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.

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted

Going now to hang my head in shame for not spotting that.

 

Mike55.

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...