Last post Dec 10, 2011 02:10 PM by hans_v
Dec 10, 2011 12:40 PM|Gabby89|LINK
I m using visual studio 2008 express running C#. i got Cart table and Checkout table in the same database which is an access file. both table have 3 same column which is ProductID,MemberID and Quantity.
So when i click a button in the Shopping cart page ,the data in Cart table are supposed to transfer to Checkout table and the data in Cart are supposed to be cleared(which i havent try yet because the transfer part is not successful.). in the configure data
source, SQL statement Insert part i wrote
INSERT INTO [Checkout] ([ProductID], [MemberID], [Quantity]) VALUES (?, ?, ?) SELECT([ProductID], [MemberID], [Quantity]) FROM [Cart] WHERE ([MemberID]=?)
and the error is (Missing semicolon (;) at end of SQL statement.) come out at the aspx.cs (adsCart.Insert(); ) when i run it. when i try to execute query in configure datasource , the error is (Unable to parse query text.)
(I have also tried another way where the code is
string MemberID = User.Identity.Name;string Product = ??? ;string Quantity =??? ; (Both ??? is the part where i do not know what to put in.) adsCart1.SelectParameters["MemberID"].DefaultValue = MemberID; adsCart1.SelectParameters["ProductID"].DefaultValue = ProductID; adsCart1.SelectParameters["Quantity"].DefaultValue = Quantity; adsCheckout.InsertParameters["ProductID"].DefaultValue = ProductID; adsCheckout.InsertParameters["MemberID"].DefaultValue = MemberID; adsCheckout.InsertParameters["Quantity"].DefaultValue = Quantity; adsCheckout.Insert();
But i do not know what to put in for the 2 ??? part so i only managed to transfer the memberID to the Checkout Table.)
Sorry if the Question is too long.Please help me to solve this problem or tell me the better way to transfer data from one table to another table. I also need help in creating simple search engine for products for my website. Thanks in advance.
Dec 10, 2011 12:53 PM|gaikwad_anil1987|LINK
Blow code will help you
INSERT INTO [Checkout]
([ProductID], [MemberID], [Quantity])
SELECT([ProductID], [MemberID], [Quantity])
Dec 10, 2011 01:19 PM|Gabby89|LINK
it still wont work. i find that in configure source ,configure SQL statement the insert part, cannot put select statement into it. it just wont run.
Dec 10, 2011 02:10 PM|hans_v|LINK
find that in configure source ,configure SQL statement the insert part, cannot put select statement into it. it just wont run
If I look in your code, I suspect you're using Access? You must realize that the wizards in Visual studio don't support Access completely. For example, an insert statement with a SELECT statement are not supported. So you need to do this manually. Can you
show us your complet code?