Syntax Error in Line 1 of Stored Procedure

G

Guest

I have a Windows Form application that is calling a stored procedure to
insert a record into a SQL Server 2000 database table. I am using a
SqlConnection/SqlCommand object pair. When I execute the procedure from C#
code I get an exception with the message, "Line 1: Incorrect syntax near
'up_AddOrganization'". I can execute the procedure without difficulty in SQL
Analyzer and in the Visual Studion explorer. Why does it not execute from my
code?

The stored procedure:
ALTER PROCEDURE up_AddOrganization
@org varchar(30),
@address1 varchar(30),
@address2 varchar(30) = NULL,
@city varchar(20),
@state char(2),
@zip varchar(10),
@phone varchar(15),
@fax varchar(15) = NULL,
@url varchar(50),
@id int OUTPUT
/*
-------------------------------------------------------------
Please update this header when you edit the procedure!!!!
-------------------------------------------------------------
Brief Description:
Adds a NAICS code and title
Parameters:

@org varchar(30) - Organization name

@address1 varchar(30) - Organization address - Line 1

@address2 varchar(30) - Organization address - Line 2, can be NULL

@city varchar(20) - Organization city

@state char(2) - Organization state

@zip varchar(10) - Organization zipcode

@phone varchar(15) - Organization phone number

@fax varchar(15) - Orgainization FAX number, can be NULL

@url varchar(50) - Organization Website

@id int - Organization Identifier, OUTPUT

Author:
Leonard E. James
Update history:
Date Author Description
-------- ---------- --------------------------------------
4/23/05 Leonard Created
-------------------------------------------------------------
-------------------------------------------------------------
*/
AS

INSERT INTO dbo.NetworkOrg
(
orgName,
orgAddress1,
orgAddress2,
orgCity,
orgState,
orgZip,
phone,
fax,
url
)
VALUES
(
@org,
@address1,
@address2,
@city,
@state,
@zip,
@phone,
@fax,
@url
)

SELECT @id = SCOPE_IDENTITY()

RETURN
 
G

Guest

You didn't post your C# code, but I'm guessing that you forgot to set the
CommandType to Stored Proc:

MySqlCommand.CommandType = CommandType.StoredProcedure;

If that's not it, post the corresponding C# code snippets.

~~Bonnie
 
G

Guest

I knew it was something simple. I had seen this before. I was
copying-pasting-modifying existing code and missed that statement. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top