mike55 Posted November 4, 2006 Posted November 4, 2006 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. Quote 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)
Administrators PlausiblyDamp Posted November 4, 2006 Administrators Posted November 4, 2006 Have you tried cmdSQL.CommandType = CommandType.StoredProcedure before executing the stored proc? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mike55 Posted November 4, 2006 Author Posted November 4, 2006 Going now to hang my head in shame for not spotting that. Mike55. Quote 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)
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.