protected override int ExecuteInternal() { Bindings = new List <QueryParameterBinding>(); if (PrimaryIndexes.Length > 1) { throw new NotImplementedException("Inheritance is not implemented"); } SqlInsert insert = SqlDml.Insert(SqlDml.TableRef(PrimaryIndexes[0].Table)); setOperation.Statement = SetStatement.Create(insert); setOperation.AddValues(); QueryCommand command = ToCommand(insert); return(command.ExecuteNonQuery()); }
public static bool UpdateLineNumber(int rn, int ln) { int Line_Number = ln; int Receipt_Number = rn; //string commandstringtext; try { //Code to check for last line number for the reciept number string connString = Properties.Settings.Default.ArchiveConnectionString; //get connection string from the application settings System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(Properties.Settings.Default.ConnectionString); // Instantiate connection object conn.Open(); // SqlCommandBuilder cmdBuilder; //using sql command builder to create update command SqlCommand QueryCommand = null; //query string //get receipt numbers data from archive database DataSet dt = new DataSet(); if (Properties.Settings.Default.Mode.ToString() == "Test") //check for test mode and use test archive if test mode { QueryCommand = new SqlCommand("INSERT INTO [ImportDataWarehouse].[dbo].[Last_Line_Number_Test] " + "([Receipt_Number], [Last_Line_Number]) " + "VALUES(" + Receipt_Number + ", " + Line_Number + ")", conn); } else { QueryCommand = new SqlCommand("INSERT INTO [ImportDataWarehouse].[dbo].[Last_Line_Number] " + "([Receipt_Number], [Last_Line_Number]) " + "VALUES(" + Receipt_Number + ", " + Line_Number + ")", conn); } QueryCommand.ExecuteNonQuery(); conn.Close(); } catch (Exception ex) { MessageBox.Show("Failed last line number update. Contact administater or see error log for more informaion."); Error_Logging el = new Error_Logging("Error trying to update the last line number. \n" + "Error message is: \n" + ex); } return(true); }
protected override int ExecuteInternal() { base.ExecuteInternal(); QueryTranslationResult request = GetRequest(query); Bindings = request.ParameterBindings.ToList(); if (PrimaryIndexes.Length > 1) { throw new NotImplementedException("Inheritance is not implemented"); } SqlDelete delete = SqlDml.Delete(SqlDml.TableRef(PrimaryIndexes[0].Table)); Join(delete, (SqlSelect)request.Query); QueryCommand command = ToCommand(delete); int result = command.ExecuteNonQuery(); return(result); }
protected override int ExecuteInternal() { base.ExecuteInternal(); QueryTranslationResult request = GetRequest(query); Bindings = request.ParameterBindings.ToList(); if (PrimaryIndexes.Length > 1) { throw new NotImplementedException("Inheritance is not implemented"); } SqlUpdate update = SqlDml.Update(SqlDml.TableRef(PrimaryIndexes[0].Table)); setOperation.Statement = SetStatement.Create(update); Join(update, (SqlSelect)request.Query); setOperation.AddValues(); QueryCommand command = ToCommand(update); return(command.ExecuteNonQuery()); }