M
Mike P
Can somebody please tell me if I am going about this task the right way?
I have a recordset that I want to read and then perform a test and an
update on each record in the recordset. Should I use a datareader to
read the data and then a foreach loop to do my test and update? And if
so, what would the syntax of my foreach loop be?
string strGetCartDetails = "SELECT S.PRODUCTID AS 'Product ID', ";
strGetCartDetails += "'£5.00' AS 'Unit Price (GBP)', S.SIPDOMAIN
AS 'SIP Domain', ";
strGetCartDetails += "S.QUANTITY as 'Quantity', C.SIPACCOUNT AS
'SIP Account', N.STARTRANGE, N.ENDRANGE ";
strGetCartDetails += "FROM NUMBER_RANGES N INNER JOIN ";
strGetCartDetails += "SHOPPING_CART S ON ";
strGetCartDetails += "S.PRODUCTID = N.RECORDNUM ";
strGetCartDetails += "INNER JOIN SHOPPING_CART_SIP C ON ";
strGetCartDetails += "C.SCRECORDID = S.SCRECORDID ";
strGetCartDetails += "WHERE S.CARTID = '" + strCartID + "' ";
strGetCartDetails += "ORDER BY N.RECORDNUM";
SqlConnection objConnectionGetCartDetails = new
SqlConnection(ConfigurationSettings.AppSettings["strConnectTest"]);
SqlDataReader objDataReaderGetCartDetails = null;
SqlCommand objCommandGetCartDetails = new
SqlCommand(strGetCartDetails, objConnectionGetCartDetails);
objConnectionGetCartDetails.Open();
objDataReaderGetCartDetails =
objCommandGetCartDetails.ExecuteReader();
if (objDataReaderGetCartDetails.Read() == true)
{
//do foreach
}
Any help would be really appreciated.
Cheers,
Mike
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
I have a recordset that I want to read and then perform a test and an
update on each record in the recordset. Should I use a datareader to
read the data and then a foreach loop to do my test and update? And if
so, what would the syntax of my foreach loop be?
string strGetCartDetails = "SELECT S.PRODUCTID AS 'Product ID', ";
strGetCartDetails += "'£5.00' AS 'Unit Price (GBP)', S.SIPDOMAIN
AS 'SIP Domain', ";
strGetCartDetails += "S.QUANTITY as 'Quantity', C.SIPACCOUNT AS
'SIP Account', N.STARTRANGE, N.ENDRANGE ";
strGetCartDetails += "FROM NUMBER_RANGES N INNER JOIN ";
strGetCartDetails += "SHOPPING_CART S ON ";
strGetCartDetails += "S.PRODUCTID = N.RECORDNUM ";
strGetCartDetails += "INNER JOIN SHOPPING_CART_SIP C ON ";
strGetCartDetails += "C.SCRECORDID = S.SCRECORDID ";
strGetCartDetails += "WHERE S.CARTID = '" + strCartID + "' ";
strGetCartDetails += "ORDER BY N.RECORDNUM";
SqlConnection objConnectionGetCartDetails = new
SqlConnection(ConfigurationSettings.AppSettings["strConnectTest"]);
SqlDataReader objDataReaderGetCartDetails = null;
SqlCommand objCommandGetCartDetails = new
SqlCommand(strGetCartDetails, objConnectionGetCartDetails);
objConnectionGetCartDetails.Open();
objDataReaderGetCartDetails =
objCommandGetCartDetails.ExecuteReader();
if (objDataReaderGetCartDetails.Read() == true)
{
//do foreach
}
Any help would be really appreciated.
Cheers,
Mike
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!