Very strange error

  • Thread starter Thread starter Alberto
  • Start date Start date
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.
 
My SQL Server knowledge is very limited but I think syntax for the procedure
is without parenthesses '( )'
 
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.
 
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.
 
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.
 
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
 
Back
Top