I have an insert method that works fine with smaller data sets, but once the data sets get beyond a certain size , the method times out, regardless of what i set in the initial transaction scope.
the insert methods in the code use simple stored sql procedures that are called with "ExecuteNonQuery"
My code looks something like this (fluff removed):
public void method()
{
using (TransactionScope testScope = new TransactionScope(TransactionScopeOption.Required, new System.TimeSpan(1, 25, 0)))
{
timeDB.insert(var.time);
codeDB.insert(var.code);
foreach (variable var in listOfVariables)
{
nameDB.insert(var.value);
}
testScope.Complete();
}
}
I assume the issue has something to do with the command time out rather than the scope time out, since the code works fine for the smaller Datasets.... if that's the case is there any way to change the command time out without modify machine.config (or any other .config files, I'm strictly banned from modifying them as changing the values would mess up the rest of the program)
If the issue ISN'T the specific command time outs, what is causing it? Like i said the code works fine with anywhere between 8000-15000 inserts (depending on the timeout set in our ConnectionString "Connect Timeout value set in our program config file that i can only modify for test purposes but cannot change any value within), but anything larger than that and it crashes.
also i'm sure it's definitely not the scope timeout value as the task timesout after about a few minutes, no where near the 1 hour and 25 minutes set in the transactionscope
Thank you in advance for taking the time to help me fix this issue.
Edit:
By request i've added an example of one of the insert methods that is eventually called by the nameDB.insert method (Fluff removed, note that the actual insert method is actually a sub method of the NameDB.insert method, and the actual loop is in that nameDB.insert method . I just used NameDB....etc to lessen the fluff. )
public Int32 Insert(Hashtable serData, DataDO data)
{
int numAffected = 0;
IDataParameter[] parameters =
{
this.Helper.GetParameter("@Text", data.Text),
this.Helper.GetParameter("@CreationDt", ((data.CreationDate == DateTime.MinValue)
? Convert.DBNull : data.CreationDate)),
this.Helper.GetParameter("@TypeId", data.TypeId),
this.Helper.GetParameter("@KeyId", DbType.Int32, 4, ParameterDirection.Output)
};
numAffected = this.Helper.ExecuteNonQuery(this.ConnectionString, "InsertData", parameters);
if (numAffected > 0)
return Convert.ToInt32(parameters[parameters.Length - 1].Value);
return 0;
}