Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Stored procedure problem

Reply
Thread Tools

Stored procedure problem

 
 
martinharvey via DotNetMonster.com
Guest
Posts: n/a
 
      11-28-2005
This is probably a very simple question but i am having problems with a
stored procedure syntax.

I want to insert into a Datatable ("Orders") "Name" and "Address" from a
datatable called "customer"
with the parameters customerId = @CustomerId

I also want to insert into the same Datatable ("orders") at the same time
"Name" and "Cost"
from a datatable called "products". The input parameter for this is cartID =
@cartId

I have tried this but it doesnt seem to work. Can anyone tell me where i am
going wrong.

CREATE PROCEDURE SP_CreateOrder
(@CustomerID Varchar (50), @CartID Char (36))

AS

INSERT INTO Orders (Name, Address, Name, Cost)

SELECT customer.Name, customer.Address, products.Name, products.Cost

FROM Customer AND Products Join ShoppingCart ON Products.ProductID =
ShoppingCart.ProductID

WHERE ShoppingCart.CartID = @CartID AND customerId = @CustomerId

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...p-net/200511/1
 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      11-28-2005
Your FROM clause in invalid. Look up T-SQL syntax for joins in any resource
available to you. It is hard to give a more precise advise without knowing
your tables structure and what exactly you want to achieve.

Eliyahu

"martinharvey via DotNetMonster.com" <u14945@uwe> wrote in message
news:5807489da7800@uwe...
> This is probably a very simple question but i am having problems with a
> stored procedure syntax.
>
> I want to insert into a Datatable ("Orders") "Name" and "Address" from a
> datatable called "customer"
> with the parameters customerId = @CustomerId
>
> I also want to insert into the same Datatable ("orders") at the same time
> "Name" and "Cost"
> from a datatable called "products". The input parameter for this is cartID
> =
> @cartId
>
> I have tried this but it doesnt seem to work. Can anyone tell me where i
> am
> going wrong.
>
> CREATE PROCEDURE SP_CreateOrder
> (@CustomerID Varchar (50), @CartID Char (36))
>
> AS
>
> INSERT INTO Orders (Name, Address, Name, Cost)
>
> SELECT customer.Name, customer.Address, products.Name, products.Cost
>
> FROM Customer AND Products Join ShoppingCart ON Products.ProductID =
> ShoppingCart.ProductID
>
> WHERE ShoppingCart.CartID = @CartID AND customerId = @CustomerId
>
> --
> Message posted via DotNetMonster.com
> http://www.dotnetmonster.com/Uwe/For...p-net/200511/1



 
Reply With Quote
 
 
 
 
=?Utf-8?B?VmVua2F0X0tM?=
Guest
Posts: n/a
 
      11-28-2005
Dear martinharvey,

(viaotNetMonster.com)

There is no AND if you are working on two tables, it is only ( , ) comma;
With Comma, It works fine:

CREATE PROCEDURE SP_CreateOrder
(@CustomerID Varchar (50), @CartID Char (36))
AS
INSERT INTO Orders (Name,Address,ProductName,Cost)
SELECT customer.Name, customer.Address, products.ProductName,products.Cost
FROM Customer , Products Join ShoppingCart ON Products.ProductID =
ShoppingCart.ProductID WHERE ShoppingCart.CartID = @CartID AND customerId =
@CustomerId

Bye
Venkat_KL
 
Reply With Quote
 
martinharvey via DotNetMonster.com
Guest
Posts: n/a
 
      11-28-2005
Eliyahu Goldin wrote:
>Your FROM clause in invalid. Look up T-SQL syntax for joins in any resource
>available to you. It is hard to give a more precise advise without knowing
>your tables structure and what exactly you want to achieve.
>
>Eliyahu
>
>> This is probably a very simple question but i am having problems with a
>> stored procedure syntax.

>[quoted text clipped - 26 lines]
>>
>> WHERE ShoppingCart.CartID = @CartID AND customerId = @CustomerId


many thanks for your help again Eliyahu
mart

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...p-net/200511/1
 
Reply With Quote
 
martinharvey via DotNetMonster.com
Guest
Posts: n/a
 
      11-28-2005
Venkat_KL wrote:
>Dear martinharvey,
>
>(viaotNetMonster.com)
>
>There is no AND if you are working on two tables, it is only ( , ) comma;
>With Comma, It works fine:
>
>CREATE PROCEDURE SP_CreateOrder
>(@CustomerID Varchar (50), @CartID Char (36))
>AS
>INSERT INTO Orders (Name,Address,ProductName,Cost)
>SELECT customer.Name, customer.Address, products.ProductName,products.Cost
>FROM Customer , Products Join ShoppingCart ON Products.ProductID =
>ShoppingCart.ProductID WHERE ShoppingCart.CartID = @CartID AND customerId =
>@CustomerId
>
>Bye
>Venkat_KL


This was very helpful I will give it a try

many thanks

martin

--
Message posted via http://www.dotnetmonster.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
'Procedure or function <stored procedure name> has too many arguments specified',,,ARGH! Mike P ASP .Net 0 06-19-2006 01:19 PM
Stored Procedure problem The Clansman ASP .Net 1 05-18-2004 11:32 PM
Interesting Stored Procedure Problem.. Bilbo ASP .Net 3 11-20-2003 09:31 PM
Stored Procedure/Parameter problem ElmoWatson ASP .Net 1 08-06-2003 01:19 AM
Stored Procedure Problem Leon Shaw ASP .Net 1 07-29-2003 09:19 AM



Advertisments