public bool ExecuteNonQueryStatements() { SqlConnection cn = null; cn = new SqlConnection(CommonFunctions.ConStr); cn.Open(); SqlTransaction myTrans; myTrans = cn.BeginTransaction(); //cmd.Transaction = myTrans; int cntEntry = 0; try { for (int i = 0; (i < this.commandcollection.Count); i = (i + 1)) { if ((this.commandcollection[i] != null)) { commandcollection[i].Connection = cn; commandcollection[i].Transaction = myTrans; if (commandcollection[i].CommandText == "AddMRecipeMain") { cntEntry = i; } if (commandcollection[i].CommandText == "AddMRecipeSub") { commandcollection[i].Parameters.AddWithValue("@FKMRecipeID", commandcollection[cntEntry].Parameters["@ReturnID"].Value); } if (commandcollection[i] != null) { commandcollection[i].ExecuteNonQuery(); } } } myTrans.Commit(); return(true); } catch (Exception e) { myTrans.Rollback(); if (e.GetBaseException().Message == "") { strerrormsg = e.Message; } else { strerrormsg = e.GetBaseException().Message; } return(false); } finally { commandcollection.Clear(); cn.Close(); } //________________________________________________________________________________________________________________________________________________________________________________________________________________________ }
public bool ExecuteNonQueryStatements1() { SqlConnection cn = null; cn = new SqlConnection(CommonFunctions.ConStr); cn.Open(); SqlTransaction myTrans; myTrans = cn.BeginTransaction(); try { for (int i = 0; (i < this.commandcollection.Count); i = (i + 1)) { if ((this.commandcollection[i] != null)) { commandcollection[i].Connection = cn; commandcollection[i].Transaction = myTrans; if (commandcollection[i] != null) { commandcollection[i].ExecuteNonQuery(); } } } myTrans.Commit(); commandcollection.Clear(); return(true); } catch (Exception e) { myTrans.Rollback(); if (e.GetBaseException().Message == "") { strerrormsg = e.Message; } else { strerrormsg = e.GetBaseException().Message; } return(false); } finally { cn.Close(); } //________________________________________________________________________________________________________________________________________________________________________________________________________________________ }
public void Flush() { if (Commands.Count == 0) { UpdateDescriptor(); return; } UpdateDescriptor(); var result = StorageEngine.Execute(IndexDescriptor, Commands); SetResult(Commands, result); Commands.Clear(); }
/// <summary> /// Updates the local descriptor with the changes from the remote /// and retrieves up to date descriptor from the local server. /// </summary> private void UpdateDescriptor() { ICommand command = null; CommandCollection collection = new CommandCollection(1); // Set the local descriptor command = new XTableDescriptorSetCommand(this.Descriptor); collection.Add(command); StorageEngine.Execute(this.Descriptor, collection); // Get the local descriptor command = new XTableDescriptorGetCommand(this.Descriptor); collection.Clear(); collection.Add(command); collection = StorageEngine.Execute(this.Descriptor, collection); XTableDescriptorGetCommand resultCommand = (XTableDescriptorGetCommand)collection[0]; this.Descriptor = resultCommand.Descriptor; }
/// <summary> /// Clears the command(s). /// </summary> public void Clear() { _commands.Clear(); _currentCommand = null; }
/// <summary> /// Clears all commands from the queue. /// </summary> public void Clear() { commands.Clear(); }