Subject: Chapter 13 Shopping Cart
Posted By: michaelcode Post Date: 9/2/2006 4:57:15 PM
In Checkout.aspx the line below

OrderID = Convert.ToInt32(cmd.ExecuteScalar())

OrderID is always 0 when inserted into table OrderLines

Can anyone please advise.

thanks,
Michael.



Reply By: Alexi Reply Date: 9/11/2006 1:41:00 AM
Hi,
Might be because you haven't debugged and there is an error on p.479 - Evel should have brackets around.i.e. Eval("ProductID", "WroxShopItem.aspx?ProductID={0}")

Reply By: Alexi Reply Date: 10/5/2006 5:43:48 AM
Hey, I finally found the answer if you are still interested:

you add this to the end of the first INSERT SQL statement: & _
        "SELECT @@IDENTITY AS OrderID;" and it works fine

Reply By: DanM Reply Date: 10/13/2006 9:09:40 AM
michaelcode,

As noted in this thread - http://p2p.wrox.com/topic.asp?TOPIC_ID=40977 - you might also want to try using

'SELECT SCOPE_IDENTITY() AS OrderID'

as well.

dan

Dan Maharry
Read the feed at http://feeds.feedburner.com/dansarchive
Reply By: Zhu-ShengJun Reply Date: 5/24/2007 6:57:53 PM
Hi,
I'm using VWD 2005 Express with C#.
cmd.CommandText = "INSERT INTO Orders(MemberName,OrderDate,Name,Address,County,PostCode,Country,Total)" +
                "VALUES (@MemberName,@OrderDate,@Name,@Address,@County,@PostCode,@Country,@Total)"+"SELECT @@IDENTITY AS OrderID";
It is OK now.


Go to topic 60956

Return to index page 1