473,385 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Very strange error

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.

Nov 16 '05 #1
7 1145
My SQL Server knowledge is very limited but I think syntax for the procedure
is without parenthesses '( )'
"Alberto" <al*****@nospam.com> wrote in message
news:%2*****************@TK2MSFTNGP10.phx.gbl...
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.

Nov 16 '05 #2
I try it without the parenthesses and the error it's the same.
Thank you.

"Bastian" <ra****@quicknet.nl> escribió en el mensaje
news:%2******************@TK2MSFTNGP10.phx.gbl...
My SQL Server knowledge is very limited but I think syntax for the procedure is without parenthesses '( )'
"Alberto" <al*****@nospam.com> wrote in message
news:%2*****************@TK2MSFTNGP10.phx.gbl...
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.


Nov 16 '05 #3
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.

Alberto wrote:
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.

Nov 16 '05 #4
"Alberto" <al*****@nospam.com> wrote:
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.
Nov 16 '05 #5
He has the "AS" in the proper spot, which is after the parameters.
"Alberto" <al*****@nospam.com> wrote:

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.

Nov 16 '05 #6
The CommandType it's set to StoredProcedure.
Thank you.

"Mike Newton" <MN*****@Addus.com> escribió en el mensaje
news:eJ******************@TK2MSFTNGP09.phx.gbl...
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.

Alberto wrote:
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.

Nov 16 '05 #7

"Alberto" <al*****@nospam.com> wrote in message news:%2*****************@TK2MSFTNGP10.phx.gbl...
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
Nov 16 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Shelly | last post by:
I have come across a strange problem. I am setting up a registration screen with username, password, confirm password, and a couple of other things. The submit button is named "Submit". The...
14
by: Allcomp | last post by:
Hello, I have seen something really strange in VB6 If I do a Int ( (5 * 1.2)) , I receive the value 5, but I should receive 6? Is this a bug or something really "normal". I can see that if I...
6
by: leonecla | last post by:
Hi everybody, I'm facing a very very strange problem with a very very simple C program... My goal should be to write to a binary file some numbers (integers), each one represented as a sequence...
2
by: TB | last post by:
I am seeing a very strange problem as follows... I have a loop where a fair amount of processing is going on and near the top of the loop I access a class that has only static helper functions...
5
by: cody | last post by:
I have a very funny/strange effect here. if I let the delegate do "return prop.GetGetMethod().Invoke(info.AudioHeader, null);" then I get wrong results, that is, a wrong method is called and I...
2
by: Shapper | last post by:
Hello, I have this code: Dim cultureList(,) As String = {{"E", "en-GB"}, {"P", "pt-PT"}} Select Case Session("culture") Case "pt-PT" ... Dim cultureList(,) As String =...
2
by: Buddy Ackerman | last post by:
I have a web app that I have setup on numerous web servers. I've set one up for a new client at their hosting facility and cannot get it to connect to their database. I get a "SQL Server does not...
1
by: Don Rixtown | last post by:
I ran into a very strange error tonight. I was working with web services and typed datasets. The web server I was using happens to be on the other end of a virtual network (Hamachi). Everything...
4
by: Efy | last post by:
Hi, I was debugging my JavaScript in VS2005, the script probably had an error some ware (Line 25), after I fixed the error, I am trying to run the page again I am getting the same error "Illegal...
11
by: VijaKhara | last post by:
Hi all, I just write a very simple codes in C and vthere is a very strange bug which I cannot figure out why. The first loop is for v, and the second for k. There is no relationship between v...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.