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