Hi,
I have a dataset I am trying to loop through. For each row(record)
in the dataset, I need to perform an action - in this case, insert a
new record.
The problem is this - my code is successful in looping through the
number of rows in the dataset, Unfortunatley it is inserting the
same record for each pass.
My code is below:
Dim irow As Data.DataRow
For Each irow In dsBustDataSet.Tables(0).Rows
Dim myConnection4 As New
Data.SqlClient.SqlConnection(srcPage2.ConnectionString)
Dim cmdAddToCart As New
Data.SqlClient.SqlCommand()
cmdAddToCart.CommandType =
Data.CommandType.Text
cmdAddToCart.Connection = myConnection4
cmdAddToCart.CommandText = "Insert into
tblShoppingCart (intCustomerID, decPrice, intQuantity, intProductID,
strRangeName, strSize, intThemeID, intColourID, intCandyStripeID,
intPlainColourID, strChildName, strBirthDate, strFontName, intOpen)
Values (
CustomerID,
Price,
Quantity,
ProductID,
RangeName,
Size,
ThemeID,
ColourID,
CandyStripeID,
PlainColourID,
ChildName,
BirthDate,
FontName, 1)"
cmdAddToCart.Parameters.AddWithValue
("
CustomerID", Session("LoggedCustomerID").replace(".", ""))
cmdAddToCart.Parameters.AddWithValue
("
Price", dsBustDataSet.Tables("FindCartItemsQuery").Rows(0).Item
("decPrice"))
cmdAddToCart.Parameters.AddWithValue
("
Quantity", dsBustDataSet.Tables("FindCartItemsQuery").Rows(0).Item
("intQuantity")) '***column does not belong to the query - yes it
does!!!
cmdAddToCart.Parameters.AddWithValue
("
ProductID", dsBustDataSet.Tables("FindCartItemsQuery").Rows
(0).Item("intProductID"))
cmdAddToCart.Parameters.AddWithValue
("
RangeName", dsBustDataSet.Tables("FindCartItemsQuery").Rows
(0).Item("strRangeName"))
cmdAddToCart.Parameters.AddWithValue
("
Size", dsBustDataSet.Tables("FindCartItemsQuery").Rows(0).Item
("strSize"))
cmdAddToCart.Parameters.AddWithValue
("
ThemeID", dsBustDataSet.Tables("FindCartItemsQuery").Rows(0).Item
("intThemeID"))
cmdAddToCart.Parameters.AddWithValue
("
ColourID", dsBustDataSet.Tables("FindCartItemsQuery").Rows(0).Item
("intColourID"))
cmdAddToCart.Parameters.AddWithValue
("
CandyStripeID", dsBustDataSet.Tables("FindCartItemsQ