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 haven’t 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.
Use SQL are per your first thoughts. The above statement should get the values you require. All you need to do is specify a member ID in the Where clause.
More information :
http://msdn.microsoft.com/en-us/library/ms188263.aspx
http://msdn.microsoft.com/en-us/library/ms189872.aspx