I'm going about converting all of my inline SQL in my C# application
into stored procedures. I have this method below that is running an SQL
statement until a field changes. Is it a good idea to convert this to a
stored procedure, and if so should it be easy to do?
DBResult dbrChangeCCState;
string strViewAttemptedPurchase;
strViewAttemptedPurchase = "SELECT STATUS FROM ATTEMPTEDPURCHASE
WHERE SESSIONID = " + Convert.ToInt64(strSessionID) + " AND PURCHASEID =
" + Convert.ToInt64(strPurchaseID);
SqlConnection objConnection = new
SqlConnection(ConfigurationSettings.AppSettings["strConnectMcCallumTest"
]);
//SqlConnection objConnection = new
SqlConnection(ConfigurationSettings.AppSettings["strConnectMcCallumTest"
]);
SqlCommand objCommand = new SqlCommand(strViewAttemptedPurchase,
objConnection);
try
{
objConnection.Open();
SqlDataReader objDataReader = null;
objDataReader = objCommand.ExecuteReader();
if (objDataReader.Read() == true)
{
intNewStatus = Convert.ToInt32(objDataReader["STATUS"]);
}
DateTime dtmStart = DateTime.Now;
TimeSpan tsTimeout = new TimeSpan (0, 1, 0); // One minute
while ((intNewStatus == 0) || (intNewStatus == 1))
{
objDataReader.Close();
objDataReader = objCommand.ExecuteReader();
if (objDataReader.Read() == true)
{
intNewStatus = Convert.ToInt32(objDataReader["STATUS"]);
}
if (DateTime.Now-dtmStart > tsTimeout)
{
break;
}
}
dbrChangeCCState = DBResult.Valid;
}
Thanks,
Mike
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!