/// <summary> /// Process a database update /// </summary> /// <param name="SqlString">The update SQL String that will be executed on the database to update a record, [Mandatory]</param> /// <param name="Connection">Open SQL Connection, [Mandatory]</param> /// <returns>Populated BaseResponse</returns> public static Base_Response ProcessUpdate(string SqlString, SqlConnection Connection) { //creates an object of the base response class to be sent back to the variables that requested the UpdateRecord function Base_Response _Response = new Base_Response(); //SqlCommand object is declared and the SQL statement set along with the database connection. SqlCommand Comm = new SqlCommand(SqlString, Connection); //Set the timeout for the results in case the database hangs. Comm.CommandTimeout = 600; try//here incase there is an error and protects systrem from crashing { //stores the result used for executing updateRecords as it does not return any data back and if the update is successful the rows number is returned and then the _respond object can pass a response message of the createion being successful or unsuccessful string Result = Comm.ExecuteNonQuery().ToString(); if (Result != "0") { //Stores "Record Updated" in the object _Response _Response.ResponseMessage = "Record Updated"; // sets the transactioncomplete variable in the _response object to true _Response.TransactionCompleted = true; } else { _Response.ResponseMessage = "Record Not Updated"; } } catch (SqlException SqlError) { //if the try portion fails then the response message is populated with an error _Response.ResponseMessage = SqlString + SqlError.Message; } return(_Response); }