Exemplo n.º 1
0
 public int Add(row_states rs)
 {
     modified  = add_array(modified, rs.modified);
     deleted   = add_array(deleted, rs.deleted);
     added     = add_array(added, rs.added);
     unchanged = add_array(unchanged, rs.added);
     updated   = +rs.updated;
     return(updated);
 }
Exemplo n.º 2
0
        public row_states get_row_states()
        {
            row_states us = new row_states();

            us.deleted   = dataTable.Select(null, null, DataViewRowState.Deleted);
            us.added     = dataTable.Select(null, null, DataViewRowState.Added);
            us.modified  = dataTable.Select(null, null, DataViewRowState.ModifiedCurrent);
            us.unchanged = dataTable.Select(null, null, DataViewRowState.Unchanged);
            return(us);
        }
Exemplo n.º 3
0
        public int BulkUpdate()
        {
            if (_ensureConnectionOpen() == false)
            {
                return(-1);
            }

            int ret = 0;

            row_states rs = get_row_states();

            // initialise string builder to collect insert update strings
            _sb = new StringBuilder();

            // add event handller to get upadte records to compile batch sql string
            _dataAdapter.UpdateCommand = _builder.GetUpdateCommand();
            _dataAdapter.InsertCommand = _builder.GetInsertCommand();
            _dataAdapter.RowUpdating  += new SqlRowUpdatingEventHandler(da_RowUpdating);

            //  int rows = dataAdapter.Update(dataSet,tableName);
            int rows_updated = Update();
            int rows_total   = dataTable.Rows.Count;

            string s1 = _sb.ToString();

            if (s1.Length > 0)
            {
                try {
                    SqlCommand cmd = new SqlCommand(_sb.ToString(), _connection);
                    cmd.CommandTimeout = COMMAND_TIMEOUT;
                    // Execute the update command.
                    var int32Execute = cmd.ExecuteScalar();
                    //no confirmation from executescalar but return the records cound submitted
                    return(rows_total);
                } catch (Exception exception) {
                    return(-1);
                }
            }

            return(ret);
        }