Very strange error

A

Alberto

I have this store procedure to insert orders in the 'Orders' table of
NorthWind (SQL Server 2000):

CREATE PROCEDURE NuevoPedido
(
@CustomerID nchar(5),
@EmployeeID int,
@OrderDate DateTime,
@RequiredDate DateTime,
@ShipVia int,
@Freight money,
@ShipName nvarchar(40),
@ShipAddress nvarchar(60),
@ShipCity nvarchar(15),
@ShipRegion nvarchar(15),
@ShipPostalCode nvarchar(10),
@ShipCountry nvarchar(15),
@OrderID int OUTPUT
)
as
INSERT INTO Orders
(CustomerID, EmployeeID, OrderDate, RequiredDate, ShipVia, Freight,
ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry)
VALUES
(@CustomerID, @EmployeeID, @OrderDate, @RequiredDate, @ShipVia, @Freight,
@ShipName, @ShipAddress, @ShipCity, @ShipRegion, @ShipPostalCode,
@ShipCountry)

SELECT @OrderID = @@Identity

When I call it from C# I see an error who says 'Sintax error near
NuevoPedido'.

I can't find the error. Could you help me? Thank you.
 
B

Bastian

My SQL Server knowledge is very limited but I think syntax for the procedure
is without parenthesses '( )'
 
P

Paul E Collins

Alberto said:
CREATE PROCEDURE NuevoPedido
(
@CustomerID nchar(5),
@EmployeeID int,
[...]
When I call it from C# I see an error who says 'Sintax
error near NuevoPedido'.
I can't find the error. Could you help me? Thank you.

Do you need the AS keyword?

CREATE PROCEDURE NuevoPedido AS
(
....

P.
 
M

Mike Newton

If you are using an SqlCommand object, make sure that you have the line:

command.CommandType = CommandType.StoredProcedure;

Otherwise, it's going to try to execute it as text.
 
M

Mike Newton

He has the "AS" in the proper spot, which is after the parameters.
CREATE PROCEDURE NuevoPedido
(
@CustomerID nchar(5),
@EmployeeID int,
[...]
When I call it from C# I see an error who says 'Sintax
error near NuevoPedido'.
I can't find the error. Could you help me? Thank you.


Do you need the AS keyword?

CREATE PROCEDURE NuevoPedido AS
(
...

P.
 
H

Hans Kesting

Alberto said:
I have this store procedure to insert orders in the 'Orders' table of
NorthWind (SQL Server 2000):

CREATE PROCEDURE NuevoPedido
(
@CustomerID nchar(5),
@EmployeeID int,
@OrderDate DateTime,
@RequiredDate DateTime,
@ShipVia int,
@Freight money,
@ShipName nvarchar(40),
@ShipAddress nvarchar(60),
@ShipCity nvarchar(15),
@ShipRegion nvarchar(15),
@ShipPostalCode nvarchar(10),
@ShipCountry nvarchar(15),
@OrderID int OUTPUT
)
as
INSERT INTO Orders
(CustomerID, EmployeeID, OrderDate, RequiredDate, ShipVia, Freight,
ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry)
VALUES
(@CustomerID, @EmployeeID, @OrderDate, @RequiredDate, @ShipVia, @Freight,
@ShipName, @ShipAddress, @ShipCity, @ShipRegion, @ShipPostalCode,
@ShipCountry)

SELECT @OrderID = @@Identity

When I call it from C# I see an error who says 'Sintax error near
NuevoPedido'.

I can't find the error. Could you help me? Thank you.

A few questions:
- is this procedure already defined in sqlserver or is it part of the query
you want to execute from C#?
- if already in sqlserver (as it should be), can you execute it there?
- what C# code do you use to execute it?

Hans Kesting
 

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