Пример #1
0
		RowUpdatingEventArgs (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) 
		{
			this.dataRow = dataRow;
			this.command = command;
			this.statementType = statementType;
			this.tableMapping = tableMapping;
			this.status = UpdateStatus.Continue;
			this.errors = null;
		}
Пример #2
0
 public RowUpdatedEventArgs(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
 {
     switch (statementType)
     {
         case StatementType.Select:
         case StatementType.Insert:
         case StatementType.Update:
         case StatementType.Delete:
         case StatementType.Batch:
             break;
         default:
             throw ADP.InvalidStatementType(statementType);
     }
     _dataRow = dataRow;
     _command = command;
     _statementType = statementType;
     _tableMapping = tableMapping;
 }
Пример #3
0
 public RowUpdatingEventArgs(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
 {
     ADP.CheckArgumentNull(dataRow, nameof(dataRow));
     ADP.CheckArgumentNull(tableMapping, nameof(tableMapping));
     switch (statementType)
     {
         case StatementType.Select:
         case StatementType.Insert:
         case StatementType.Update:
         case StatementType.Delete:
             break;
         case StatementType.Batch:
             throw ADP.NotSupportedStatementType(statementType, nameof(RowUpdatingEventArgs));
         default:
             throw ADP.InvalidStatementType(statementType);
     }
     _dataRow = dataRow;
     _command = command; // maybe null
     _statementType = statementType;
     _tableMapping = tableMapping;
 }
Пример #4
0
 public SqlRowUpdatingEventArgs(DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
     : base(row, command, statementType, tableMapping)
 {
 }
Пример #5
0
 override protected RowUpdatingEventArgs CreateRowUpdatingEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
 {
     return(new SqlRowUpdatingEventArgs(dataRow, command, statementType, tableMapping));
 }
Пример #6
0
        private OracleCommand CreateUpdateCommand(DataRow row, DataTableMapping tableMapping)
        {
            // If no table was found, then we can't do an update
            if (QuotedTableName == String.Empty)
            {
                return(null);
            }

            CreateNewCommand(ref updateCommand);

            string        command      = String.Format("UPDATE {0} SET ", QuotedTableName);
            StringBuilder columns      = new StringBuilder();
            StringBuilder whereClause  = new StringBuilder();
            int           parmIndex    = 1;
            string        dsColumnName = String.Empty;
            bool          keyFound     = false;

            // First, create the X=Y list for UPDATE
            foreach (DataRow schemaRow in dbSchemaTable.Rows)
            {
                if (columns.Length > 0)
                {
                    columns.Append(" , ");
                }

                OracleParameter parameter = updateCommand.Parameters.Add(CreateParameter(parmIndex++, schemaRow));
                parameter.SourceVersion = DataRowVersion.Current;

                dsColumnName = parameter.SourceColumn;
                if (tableMapping != null &&
                    tableMapping.ColumnMappings.Contains(parameter.SourceColumn))
                {
                    dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
                }

                if (row != null)
                {
                    parameter.Value = row [dsColumnName, DataRowVersion.Current];
                }

                columns.Append(String.Format("{0} = {1}", GetQuotedString(parameter.SourceColumn), ":" + parameter.ParameterName));
            }

            // Now, create the WHERE clause.  This may be optimizable, but it would be ugly to incorporate
            // into the loop above.  "Premature optimization is the root of all evil." -- Knuth
            foreach (DataRow schemaRow in dbSchemaTable.Rows)
            {
                if (!IncludedInWhereClause(schemaRow))
                {
                    continue;
                }

                if (whereClause.Length > 0)
                {
                    whereClause.Append(" AND ");
                }

                bool            isKey     = (bool)schemaRow ["IsKey"];
                OracleParameter parameter = null;

                if (!isKey)
                {
                    parameter = updateCommand.Parameters.Add(CreateParameter(parmIndex++, schemaRow));
                    parameter.SourceVersion = DataRowVersion.Original;

                    dsColumnName = parameter.SourceColumn;
                    if (tableMapping != null &&
                        tableMapping.ColumnMappings.Contains(parameter.SourceColumn))
                    {
                        dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
                    }

                    if (row != null)
                    {
                        parameter.Value = row [dsColumnName, DataRowVersion.Original];
                    }

                    whereClause.Append("(");
                    whereClause.Append(String.Format(clause1, GetQuotedString(parameter.SourceColumn), ":" + parameter.ParameterName));
                    whereClause.Append(" OR ");
                }
                else
                {
                    keyFound = true;
                }

                parameter = updateCommand.Parameters.Add(CreateParameter(parmIndex++, schemaRow));
                parameter.SourceVersion = DataRowVersion.Original;

                dsColumnName = parameter.SourceColumn;
                if (tableMapping != null &&
                    tableMapping.ColumnMappings.Contains(parameter.SourceColumn))
                {
                    dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
                }

                if (row != null)
                {
                    parameter.Value = row [dsColumnName, DataRowVersion.Original];
                }

                whereClause.Append(String.Format(clause2, GetQuotedString(parameter.SourceColumn), ":" + parameter.ParameterName));

                if (!isKey)
                {
                    whereClause.Append(")");
                }
            }
            if (!keyFound)
            {
                throw new InvalidOperationException("Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.");
            }

            // We're all done, so bring it on home
            string sql = String.Format("{0}{1} WHERE ( {2} )", command, columns.ToString(), whereClause.ToString());

            updateCommand.CommandText = sql;
            return(updateCommand);
        }
Пример #7
0
        private void InitAdapter()
        {
            this._adapter = new SqlDataAdapter();
            DataTableMapping mapping = new DataTableMapping {
                SourceTable    = "Table",
                DataSetTable   = "Itms",
                ColumnMappings =
                {
                    {
                        "Id",
                        "Id"
                    },
                    {
                        "IdC",
                        "IdC"
                    },
                    {
                        "IdW",
                        "IdW"
                    },
                    {
                        "IdX",
                        "IdX"
                    },
                    {
                        "Cr8D8",
                        "Cr8D8"
                    },
                    {
                        "ChkD8",
                        "ChkD8"
                    },
                    {
                        "Nfo",
                        "Nfo"
                    }
                }
            };

            this._adapter.TableMappings.Add(mapping);
            this._adapter.DeleteCommand             = new SqlCommand();
            this._adapter.DeleteCommand.Connection  = this.Connection;
            this._adapter.DeleteCommand.CommandText = "DELETE FROM [dbo].[Itms] WHERE (([Id] = @Original_Id) AND ((@IsNull_IdC = 1 AND [IdC] IS NULL) OR ([IdC] = @Original_IdC)) AND ((@IsNull_IdW = 1 AND [IdW] IS NULL) OR ([IdW] = @Original_IdW)) AND ((@IsNull_IdX = 1 AND [IdX] IS NULL) OR ([IdX] = @Original_IdX)) AND ((@IsNull_Cr8D8 = 1 AND [Cr8D8] IS NULL) OR ([Cr8D8] = @Original_Cr8D8)) AND ((@IsNull_ChkD8 = 1 AND [ChkD8] IS NULL) OR ([ChkD8] = @Original_ChkD8)))";
            this._adapter.DeleteCommand.CommandType = CommandType.Text;
            this._adapter.DeleteCommand.Parameters.Add(new SqlParameter("@Original_Id", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "Id", DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.DeleteCommand.Parameters.Add(new SqlParameter("@IsNull_IdC", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "IdC", DataRowVersion.Original, true, null, "", "", ""));
            this._adapter.DeleteCommand.Parameters.Add(new SqlParameter("@Original_IdC", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "IdC", DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.DeleteCommand.Parameters.Add(new SqlParameter("@IsNull_IdW", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "IdW", DataRowVersion.Original, true, null, "", "", ""));
            this._adapter.DeleteCommand.Parameters.Add(new SqlParameter("@Original_IdW", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "IdW", DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.DeleteCommand.Parameters.Add(new SqlParameter("@IsNull_IdX", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "IdX", DataRowVersion.Original, true, null, "", "", ""));
            this._adapter.DeleteCommand.Parameters.Add(new SqlParameter("@Original_IdX", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "IdX", DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.DeleteCommand.Parameters.Add(new SqlParameter("@IsNull_Cr8D8", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "Cr8D8", DataRowVersion.Original, true, null, "", "", ""));
            this._adapter.DeleteCommand.Parameters.Add(new SqlParameter("@Original_Cr8D8", SqlDbType.DateTime, 0, ParameterDirection.Input, 0, 0, "Cr8D8", DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.DeleteCommand.Parameters.Add(new SqlParameter("@IsNull_ChkD8", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "ChkD8", DataRowVersion.Original, true, null, "", "", ""));
            this._adapter.DeleteCommand.Parameters.Add(new SqlParameter("@Original_ChkD8", SqlDbType.DateTime, 0, ParameterDirection.Input, 0, 0, "ChkD8", DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.InsertCommand             = new SqlCommand();
            this._adapter.InsertCommand.Connection  = this.Connection;
            this._adapter.InsertCommand.CommandText = "INSERT INTO [dbo].[Itms] ([Id], [IdC], [IdW], [IdX], [Cr8D8], [ChkD8], [Nfo]) VALUES (@Id, @IdC, @IdW, @IdX, @Cr8D8, @ChkD8, @Nfo);\r\nSELECT Id, IdC, IdW, IdX, Cr8D8, ChkD8, Nfo FROM Itms WHERE (Id = @Id)";
            this._adapter.InsertCommand.CommandType = CommandType.Text;
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Id", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "Id", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@IdC", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "IdC", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@IdW", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "IdW", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@IdX", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "IdX", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Cr8D8", SqlDbType.DateTime, 0, ParameterDirection.Input, 0, 0, "Cr8D8", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@ChkD8", SqlDbType.DateTime, 0, ParameterDirection.Input, 0, 0, "ChkD8", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Nfo", SqlDbType.NText, 0, ParameterDirection.Input, 0, 0, "Nfo", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand             = new SqlCommand();
            this._adapter.UpdateCommand.Connection  = this.Connection;
            this._adapter.UpdateCommand.CommandText = "UPDATE [dbo].[Itms] SET [Id] = @Id, [IdC] = @IdC, [IdW] = @IdW, [IdX] = @IdX, [Cr8D8] = @Cr8D8, [ChkD8] = @ChkD8, [Nfo] = @Nfo WHERE (([Id] = @Original_Id) AND ((@IsNull_IdC = 1 AND [IdC] IS NULL) OR ([IdC] = @Original_IdC)) AND ((@IsNull_IdW = 1 AND [IdW] IS NULL) OR ([IdW] = @Original_IdW)) AND ((@IsNull_IdX = 1 AND [IdX] IS NULL) OR ([IdX] = @Original_IdX)) AND ((@IsNull_Cr8D8 = 1 AND [Cr8D8] IS NULL) OR ([Cr8D8] = @Original_Cr8D8)) AND ((@IsNull_ChkD8 = 1 AND [ChkD8] IS NULL) OR ([ChkD8] = @Original_ChkD8)));\r\nSELECT Id, IdC, IdW, IdX, Cr8D8, ChkD8, Nfo FROM Itms WHERE (Id = @Id)";
            this._adapter.UpdateCommand.CommandType = CommandType.Text;
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Id", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "Id", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@IdC", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "IdC", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@IdW", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "IdW", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@IdX", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "IdX", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Cr8D8", SqlDbType.DateTime, 0, ParameterDirection.Input, 0, 0, "Cr8D8", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@ChkD8", SqlDbType.DateTime, 0, ParameterDirection.Input, 0, 0, "ChkD8", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Nfo", SqlDbType.NText, 0, ParameterDirection.Input, 0, 0, "Nfo", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Original_Id", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "Id", DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@IsNull_IdC", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "IdC", DataRowVersion.Original, true, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Original_IdC", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "IdC", DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@IsNull_IdW", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "IdW", DataRowVersion.Original, true, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Original_IdW", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "IdW", DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@IsNull_IdX", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "IdX", DataRowVersion.Original, true, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Original_IdX", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "IdX", DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@IsNull_Cr8D8", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "Cr8D8", DataRowVersion.Original, true, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Original_Cr8D8", SqlDbType.DateTime, 0, ParameterDirection.Input, 0, 0, "Cr8D8", DataRowVersion.Original, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@IsNull_ChkD8", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "ChkD8", DataRowVersion.Original, true, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Original_ChkD8", SqlDbType.DateTime, 0, ParameterDirection.Input, 0, 0, "ChkD8", DataRowVersion.Original, false, null, "", "", ""));
        }
        /// <summary>
        /// Review .NET	Framework documentation.
        /// </summary>
        protected override int Update(DataRow[] dataRows, DataTableMapping tableMapping)
        {
            int           updated                    = 0;
            IDbCommand    command                    = null;
            StatementType statementType              = StatementType.Insert;
            ICollection <IDbConnection> connections  = new List <IDbConnection>();
            RowUpdatingEventArgs        updatingArgs = null;
            Exception updateException                = null;

            foreach (DataRow row in dataRows)
            {
                updateException = null;

                if (row.RowState == DataRowState.Detached ||
                    row.RowState == DataRowState.Unchanged)
                {
                    continue;
                }

                switch (row.RowState)
                {
                case DataRowState.Unchanged:
                case DataRowState.Detached:
                    continue;

                case DataRowState.Added:
                    command       = InsertCommand;
                    statementType = StatementType.Insert;
                    break;

                case DataRowState.Modified:
                    command       = UpdateCommand;
                    statementType = StatementType.Update;
                    break;

                case DataRowState.Deleted:
                    command       = DeleteCommand;
                    statementType = StatementType.Delete;
                    break;
                }

                /* The order of	execution can be reviewed in the .NET 1.1 documentation
                 *
                 * 1. The values in	the	DataRow	are	moved to the parameter values.
                 * 2. The OnRowUpdating	event is raised.
                 * 3. The command executes.
                 * 4. If the command is	set	to FirstReturnedRecord,	then the first returned	result is placed in	the	DataRow.
                 * 5. If there are output parameters, they are placed in the DataRow.
                 * 6. The OnRowUpdated event is	raised.
                 * 7 AcceptChanges is called.
                 */

                try
                {
                    updatingArgs = CreateRowUpdatingEvent(row, command, statementType, tableMapping);

                    /* 1. Update Parameter values (It's	very similar to	what we
                     * are doing in	the	FbCommandBuilder class).
                     *
                     * Only	input parameters should	be updated.
                     */
                    if (command != null && command.Parameters.Count > 0)
                    {
                        try
                        {
                            UpdateParameterValues(command, statementType, row, tableMapping);
                        }
                        catch (Exception ex)
                        {
                            updatingArgs.Errors = ex;
                            updatingArgs.Status = UpdateStatus.ErrorsOccurred;
                        }
                    }

                    // 2. Raise	RowUpdating	event
                    OnRowUpdating(updatingArgs);

                    if (updatingArgs.Status == UpdateStatus.SkipAllRemainingRows)
                    {
                        break;
                    }
                    else if (updatingArgs.Status == UpdateStatus.ErrorsOccurred)
                    {
                        if (updatingArgs.Errors == null)
                        {
                            throw new InvalidOperationException("RowUpdatingEvent: Errors occurred; no additional information is available.");
                        }
                        throw updatingArgs.Errors;
                    }
                    else if (updatingArgs.Status == UpdateStatus.SkipCurrentRow)
                    {
                        updated++;
                        continue;
                    }
                    else if (updatingArgs.Status == UpdateStatus.Continue)
                    {
                        if (command != updatingArgs.Command)
                        {
                            command = updatingArgs.Command;
                        }
                        if (command == null)
                        {
                            /* Samples of exceptions thrown	by DbDataAdapter class
                             *
                             *	Update requires	a valid	InsertCommand when passed DataRow collection with new rows
                             *	Update requires	a valid	UpdateCommand when passed DataRow collection with modified rows.
                             *	Update requires	a valid	DeleteCommand when passed DataRow collection with deleted rows.
                             */
                            throw new InvalidOperationException(CreateExceptionMessage(statementType));
                        }

                        // 3. Execute the command
                        if (command.Connection.State == ConnectionState.Closed)
                        {
                            command.Connection.Open();
                            // Track command connection
                            connections.Add(command.Connection);
                        }

                        int rowsAffected = command.ExecuteNonQuery();
                        if (rowsAffected == 0)
                        {
                            throw new DBConcurrencyException(new DBConcurrencyException().Message, null, new DataRow[] { row });
                        }

                        updated++;

                        // http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=933212&SiteID=1
                        if (statementType == StatementType.Insert)
                        {
                            row.AcceptChanges();
                        }

                        /* 4. If the command is	set	to FirstReturnedRecord,	then the
                         * first returned result is	placed in the DataRow.
                         *
                         * We have nothing to do in	this case as there are no
                         * support for batch commands.
                         */

                        /* 5. Check	if we have output parameters and they should
                         * be updated.
                         *
                         * Only	output parameters should be	updated
                         */
                        if (command.UpdatedRowSource == UpdateRowSource.OutputParameters ||
                            command.UpdatedRowSource == UpdateRowSource.Both)
                        {
                            // Process output parameters
                            foreach (IDataParameter parameter in command.Parameters)
                            {
                                if ((parameter.Direction == ParameterDirection.Output ||
                                     parameter.Direction == ParameterDirection.ReturnValue ||
                                     parameter.Direction == ParameterDirection.InputOutput) &&
                                    !String.IsNullOrEmpty(parameter.SourceColumn))
                                {
                                    DataColumn column = null;

                                    DataColumnMapping columnMapping = tableMapping.GetColumnMappingBySchemaAction(
                                        parameter.SourceColumn,
                                        MissingMappingAction);

                                    if (columnMapping != null)
                                    {
                                        column = columnMapping.GetDataColumnBySchemaAction(
                                            row.Table,
                                            null,
                                            MissingSchemaAction);

                                        if (column != null)
                                        {
                                            row[column] = parameter.Value;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    row.RowError    = ex.Message;
                    updateException = ex;
                }

                if (updatingArgs != null && updatingArgs.Status == UpdateStatus.Continue)
                {
                    // 6. Raise	RowUpdated event
                    RowUpdatedEventArgs updatedArgs = CreateRowUpdatedEvent(row, command, statementType, tableMapping);
                    OnRowUpdated(updatedArgs);

                    if (updatedArgs.Status == UpdateStatus.SkipAllRemainingRows)
                    {
                        break;
                    }
                    else if (updatedArgs.Status == UpdateStatus.ErrorsOccurred)
                    {
                        if (updatingArgs.Errors == null)
                        {
                            throw new InvalidOperationException("RowUpdatedEvent: Errors occurred; no additional information available.");
                        }
                        throw updatedArgs.Errors;
                    }
                    else if (updatedArgs.Status == UpdateStatus.SkipCurrentRow)
                    {
                    }
                    else if (updatingArgs.Status == UpdateStatus.Continue)
                    {
                        // If the update result is an exception throw it
                        if (!ContinueUpdateOnError && updateException != null)
                        {
                            CloseConnections(connections);
                            throw updateException;
                        }

                        // 7. Call AcceptChanges
                        if (AcceptChangesDuringUpdate && !row.HasErrors)
                        {
                            row.AcceptChanges();
                        }
                    }
                }
                else
                {
                    // If the update result is an exception throw it
                    if (!ContinueUpdateOnError && updateException != null)
                    {
                        CloseConnections(connections);
                        throw updateException;
                    }
                }
            }

            CloseConnections(connections);

            return(updated);
        }
Пример #9
0
        /// <summary>
        /// 执行存储过程并返回DataReader-无参数
        /// </summary>
        /// <param name="queryString"></param>
        /// <param name="parameters"></param>
        /// <param name="cmdType"></param>
        /// <param name="mapping"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public int ExecuteDataSet(string queryString, DataAccessParameterCollection parameters, CommandType cmdType, DataTableMapping mapping, ref DataSet result)
        {
            DbCommand command = CreateCommand(queryString);

            command.CommandType = cmdType;
            PrepareCommand(command, parameters);
            return(ExecuteDataSet(command, mapping, ref result));
        }
Пример #10
0
        private IDbCommand BuildDeleteCommand(DataTableMapping mappings, DataRow dataRow)
        {
            if (IsEmpty(quotedBaseTableName))
            {
                return(null);
            }
            IDbCommand    command       = BuildNewCommand(deleteCommand);
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("DELETE FROM  ");
            stringBuilder.Append(QuotedBaseTableName);
            stringBuilder.Append(" WHERE ( ");
            int    pcount = 1;
            int    pindex = 0;
            int    index  = 0;
            string sql    = "";
            string tname  = null;
            string cname  = null;
            int    count  = (int)dbSchemaRows.Length;

            for (int i = 0; i < count; i++)
            {
                DataRow dBSchemaRow = dbSchemaRows[i];
                if (dBSchemaRow != null && dBSchemaRow["BaseColumnName"].ToString().Length != 0 && IncludeForDeleteWhereClause(dBSchemaRow))
                {
                    stringBuilder.Append(sql);
                    sql = " AND ";
                    object value = null;
                    string name  = sourceColumnNames[i];
                    if (mappings != null && dataRow != null)
                    {
                        value = GetParameterValue(name, mappings, dataRow, DataRowVersion.Original);
                    }
                    bool   ispk    = IsPKey(dBSchemaRow);
                    string qcolumn = QuotedColumn(dBSchemaRow["BaseColumnName"].ToString());
                    if (ispk)
                    {
                        if (Convert.IsDBNull(value))
                        {
                            stringBuilder.Append(String.Format("({0} IS NULL)", qcolumn));
                        }
                        else if (namedParameters)
                        {
                            stringBuilder.Append(String.Format("({0} = @p{1})", qcolumn, pcount));
                        }
                        else
                        {
                            stringBuilder.Append(String.Format("({0} = ?)", qcolumn));
                        }
                    }
                    else if (namedParameters)
                    {
                        stringBuilder.Append(String.Format("((@p{1} = 1 AND {0} IS NULL) OR ({0} = @p{2}))", qcolumn, pcount, (1 + pcount)));
                    }
                    else
                    {
                        stringBuilder.Append(String.Format("((? = 1 AND {0} IS NULL) OR ({0} = ?))", qcolumn));
                    }
                    if (!ispk || !Convert.IsDBNull(value))
                    {
                        IDataParameter parameter = GetNextParameter(command, pindex);
                        parameter.ParameterName = String.Concat("@p", pcount.ToString());
                        parameter.Direction     = ParameterDirection.Input;
                        if (ispk)
                        {
                            parameter.SourceColumn  = name;
                            parameter.SourceVersion = DataRowVersion.Original;
                            parameter.Value         = value;
                        }
                        else
                        {
                            parameter.SourceColumn = null;
                            parameter.Value        = (!IsNull(value) ? 0 : 1);
                        }
                        pcount++;
                        pindex++;
                        if (parameter is SharpHsqlParameter)
                        {
                            ApplyParameterInfo((SharpHsqlParameter)parameter, pcount, dBSchemaRow);
                        }
                        if (!ispk)
                        {
                            parameter.DbType = DbType.Int32;
                        }
                        if (!command.Parameters.Contains(parameter))
                        {
                            command.Parameters.Add(parameter);
                        }
                    }
                    if (!ispk)
                    {
                        IDataParameter parameter = GetNextParameter(command, pindex);
                        parameter.ParameterName = String.Concat("@p", pcount.ToString());
                        parameter.Direction     = ParameterDirection.Input;
                        parameter.SourceColumn  = name;
                        parameter.SourceVersion = DataRowVersion.Original;
                        parameter.Value         = value;
                        pcount++;
                        pindex++;
                        if (parameter is SharpHsqlParameter)
                        {
                            ApplyParameterInfo((SharpHsqlParameter)parameter, pcount, dBSchemaRow);
                        }
                        if (!command.Parameters.Contains(parameter))
                        {
                            command.Parameters.Add(parameter);
                        }
                    }
                    if (IncrementDeleteWhereCount(dBSchemaRow))
                    {
                        index++;
                    }
                }
            }
            stringBuilder.Append(" )");
            command.CommandText = stringBuilder.ToString();
            RemoveExtraParameters(command, pindex);
            deleteCommand = command;
            if (index == 0)
            {
                throw new InvalidOperationException("Dynamic SQL has not indexey information to Delete.");
            }
            if (tname == null)
            {
                return(command);
            }
            DataColumn dataColumn = GetParameterDataColumn(cname, mappings, dataRow);

            throw new InvalidOperationException("Where Clause Unspecified Value");
        }
Пример #11
0
        private IDbCommand BuildUpdateCommand(DataTableMapping mappings, DataRow dataRow)
        {
            if (IsEmpty(this.quotedBaseTableName))
            {
                return(null);
            }
            IDbCommand    command  = this.BuildNewCommand(this.updateCommand);
            int           pcount   = 1;
            int           toupdate = 0;
            int           index    = 0;
            int           filter   = 0;
            StringBuilder sb       = new StringBuilder();

            sb.Append("UPDATE ");
            sb.Append(this.QuotedBaseTableName);
            sb.Append(" SET ");
            int rows = this.dbSchemaRows.Length;

            for (int i = 0; i < rows; i++)
            {
                DataRow row = this.dbSchemaRows[i];
                if (((row != null) && (row["BaseColumnName"].ToString().Length != 0)) && !this.ExcludeFromUpdateSet(row))
                {
                    toupdate++;
                    object value = null;
                    string name  = this.sourceColumnNames[i];
                    if ((mappings != null) && (dataRow != null))
                    {
                        value = this.GetParameterUpdateValue(name, mappings, dataRow, (bool)row["IsReadOnly"]);
                        if (value == null)
                        {
                            if ((bool)row["IsReadOnly"])
                            {
                                toupdate--;
                            }

                            continue;
                        }
                    }
                    if (0 < index)
                    {
                        sb.Append(" , ");
                    }
                    sb.Append(this.QuotedColumn(row["BaseColumnName"].ToString()));
                    this.AppendParameterText(sb, pcount);
                    IDataParameter parameter = CommandBuilder.GetNextParameter(command, index);
                    parameter.ParameterName = "@p" + pcount.ToString();
                    parameter.Direction     = ParameterDirection.Input;
                    parameter.SourceColumn  = name;
                    parameter.SourceVersion = DataRowVersion.Current;
                    parameter.Value         = value;
                    if (parameter is SharpHsqlParameter)
                    {
                        this.ApplyParameterInfo((SharpHsqlParameter)parameter, pcount, row);
                    }
                    if (!command.Parameters.Contains(parameter))
                    {
                        command.Parameters.Add(parameter);
                    }
                    pcount++;
                    index++;
                }
            }
            filter = index;
            sb.Append(" WHERE ( ");
            string sql = "";

            int where = 0;
            string tname   = null;
            string colname = null;

            for (int i = 0; i < rows; i++)
            {
                DataRow row = this.dbSchemaRows[i];
                if (((row != null) && (row["BaseColumnName"].ToString().Length != 0)) && this.IncludeForUpdateWhereClause(row))
                {
                    sb.Append(sql);
                    sql = " AND ";
                    object value = null;
                    string name  = this.sourceColumnNames[i];
                    if ((mappings != null) && (dataRow != null))
                    {
                        value = this.GetParameterValue(name, mappings, dataRow, DataRowVersion.Original);
                    }
                    bool   ispk    = this.IsPKey(row);
                    string basecol = this.QuotedColumn(row["BaseColumnName"].ToString());
                    if (ispk)
                    {
                        if (Convert.IsDBNull(value))
                        {
                            sb.Append(string.Format("({0} IS NULL)", basecol));
                        }
                        else if (this.namedParameters)
                        {
                            sb.Append(string.Format("({0} = @p{1})", basecol, pcount));
                        }
                        else
                        {
                            sb.Append(string.Format("({0} = ?)", basecol));
                        }
                    }
                    else if (this.namedParameters)
                    {
                        sb.Append(string.Format("((@p{1} = 1 AND {0} IS NULL) OR ({0} = @p{2}))", basecol, pcount, 1 + pcount));
                    }
                    else
                    {
                        sb.Append(string.Format("((? = 1 AND {0} IS NULL) OR ({0} = ?))", basecol));
                    }
                    if (!ispk || !Convert.IsDBNull(value))
                    {
                        IDataParameter parameter = CommandBuilder.GetNextParameter(command, index);
                        parameter.ParameterName = "@p" + pcount.ToString();
                        parameter.Direction     = ParameterDirection.Input;
                        if (ispk)
                        {
                            parameter.SourceColumn  = name;
                            parameter.SourceVersion = DataRowVersion.Original;
                            parameter.Value         = value;
                        }
                        else
                        {
                            parameter.SourceColumn = null;
                            parameter.Value        = IsNull(value) ? 1 : 0;
                        }
                        pcount++;
                        index++;
                        if (parameter is SharpHsqlParameter)
                        {
                            this.ApplyParameterInfo((SharpHsqlParameter)parameter, pcount, row);
                        }
                        if (!ispk)
                        {
                            parameter.DbType = DbType.Int32;
                        }
                        if (!command.Parameters.Contains(parameter))
                        {
                            command.Parameters.Add(parameter);
                        }
                    }
                    if (!ispk)
                    {
                        IDataParameter parameter = CommandBuilder.GetNextParameter(command, index);
                        parameter.ParameterName = "@p" + pcount.ToString();
                        parameter.Direction     = ParameterDirection.Input;
                        parameter.SourceColumn  = name;
                        parameter.SourceVersion = DataRowVersion.Original;
                        parameter.Value         = value;
                        pcount++;
                        index++;
                        if (parameter is SharpHsqlParameter)
                        {
                            this.ApplyParameterInfo((SharpHsqlParameter)parameter, pcount, row);
                        }
                        if (!command.Parameters.Contains(parameter))
                        {
                            command.Parameters.Add(parameter);
                        }
                    }
                    if (this.IncrementUpdateWhereCount(row))
                    {
                        where++;
                    }
                }
            }
            sb.Append(" )");
            command.CommandText = sb.ToString();
            CommandBuilder.RemoveExtraParameters(command, index);
            this.updateCommand = command;
            if (toupdate == 0)
            {
                throw new InvalidOperationException("Dynamic SQL is read only.");
            }
            if (filter == 0)
            {
                command = null;
            }
            if (where == 0)
            {
                throw new InvalidOperationException("Dynamic SQL has no primary key information to perform an update.");
            }
            if (tname != null)
            {
                DataColumn col = this.GetParameterDataColumn(colname, mappings, dataRow);
                throw new InvalidOperationException("Where Clause Unspecified Value");
            }
            return(command);
        }
Пример #12
0
        private IDbCommand BuildInsertCommand(DataTableMapping mappings, DataRow dataRow)
        {
            if (IsEmpty(this.quotedBaseTableName))
            {
                return(null);
            }
            IDbCommand    command = this.BuildNewCommand(this.insertCommand);
            int           pcount  = 0;
            int           idx     = 1;
            StringBuilder sb      = new StringBuilder();

            sb.Append("INSERT INTO ");
            sb.Append(this.QuotedBaseTableName);
            int rows = this.dbSchemaRows.Length;

            for (int i = 0; i < rows; i++)
            {
                DataRow row = this.dbSchemaRows[i];
                if ((((row == null) || (row["BaseColumnName"].ToString().Length == 0)) || ((bool)row["IsAutoIncrement"] || (bool)row["IsHidden"])) || ((bool)row["IsExpression"] || (bool)row["IsRowVersion"]))
                {
                    continue;
                }
                object value = null;
                string name  = this.sourceColumnNames[i];
                if ((mappings != null) && (dataRow != null))
                {
                    value = this.GetParameterInsertValue(name, mappings, dataRow, (bool)row["IsReadOnly"]);
                    if (value == null)
                    {
                        if (!(bool)row["IsReadOnly"] && !(command is SharpHsqlCommand))
                        {
                            goto Close;
                        }
                        continue;
                    }
                    if (Convert.IsDBNull(value) && !(bool)row["AllowDBNull"])
                    {
                        continue;
                    }
                }
Close:
                if (pcount == 0)
                {
                    sb.Append("( ");
                }
                else
                {
                    sb.Append(" , ");
                }
                sb.Append(this.QuotedColumn(row["BaseColumnName"].ToString()));
                IDataParameter parameter = CommandBuilder.GetNextParameter(command, pcount);
                parameter.ParameterName = "@p" + idx.ToString();
                parameter.Direction     = ParameterDirection.Input;
                parameter.SourceColumn  = name;
                parameter.SourceVersion = DataRowVersion.Current;
                parameter.Value         = value;
                if (parameter is SharpHsqlParameter)
                {
                    this.ApplyParameterInfo((SharpHsqlParameter)parameter, idx, row);
                }
                if (!command.Parameters.Contains(parameter))
                {
                    command.Parameters.Add(parameter);
                }
                pcount++;
                idx++;
            }
            if (pcount == 0)
            {
                sb.Append(" DEFAULT VALUES");
            }
            else if (this.namedParameters)
            {
                sb.Append(" ) VALUES ( @p1");
                for (int num5 = 2; num5 <= pcount; num5++)
                {
                    sb.Append(" , @p");
                    sb.Append(num5.ToString());
                }
                sb.Append(" )");
            }
            else
            {
                sb.Append(" ) VALUES ( ?");
                for (int num6 = 2; num6 <= pcount; num6++)
                {
                    sb.Append(" , ?");
                }
                sb.Append(" )");
            }
            command.CommandText = sb.ToString();
            CommandBuilder.RemoveExtraParameters(command, pcount);
            this.insertCommand = command;
            return(command);
        }
Пример #13
0
 public VirtuosoRowUpdatingEventArgs(DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
     : base(row, command, statementType, tableMapping)
 {
     Debug.WriteLineIf(CLI.FnTrace.Enabled, "VirtuosoRowUpdatingEventArgs.ctor()");
     Debug.WriteLineIf(VirtuosoDataAdapter.Switch.Enabled,
                       "  TableMapping " + (TableMapping == null ? "==" : "!=") + " null");
 }
Пример #14
0
 override protected RowUpdatingEventArgs CreateRowUpdatingEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
 {
     Debug.WriteLineIf(CLI.FnTrace.Enabled, "VirtuosoDataAdapter.CreateRowUpdatingEvent()");
     Debug.WriteLineIf(Switch.Enabled, "  tableMapping " + (tableMapping == null ? "==" : "!=") + " null");
     return(new VirtuosoRowUpdatingEventArgs(dataRow, command, statementType, tableMapping));
 }
        private void InitAdapter()
        {
            this._adapter = new MySqlDataAdapter();
            DataTableMapping mapping = new DataTableMapping {
                SourceTable    = "Table",
                DataSetTable   = "tbl_customer",
                ColumnMappings =
                {
                    {
                        "customer_id",
                        "customer_id"
                    },
                    {
                        "name",
                        "name"
                    },
                    {
                        "address",
                        "address"
                    },
                    {
                        "contact",
                        "contact"
                    },
                    {
                        "email",
                        "email"
                    },
                    {
                        "comments",
                        "comments"
                    },
                    {
                        "fathers_name",
                        "fathers_name"
                    },
                    {
                        "type",
                        "type"
                    }
                }
            };

            this._adapter.TableMappings.Add(mapping);
            this._adapter.DeleteCommand             = new MySqlCommand();
            this._adapter.DeleteCommand.Connection  = this.Connection;
            this._adapter.DeleteCommand.CommandText = "DELETE FROM `tbl_customer` WHERE ((`customer_id` = @p1) AND (`name` = @p2) AND (`address` = @p3) AND (`contact` = @p4) AND (`email` = @p5) AND (`comments` = @p6) AND (`fathers_name` = @p7) AND (`type` = @p8))";
            this._adapter.DeleteCommand.CommandType = CommandType.Text;
            MySqlParameter parameter = new MySqlParameter {
                ParameterName = "@p1",
                DbType        = DbType.UInt32,
                MySqlDbType   = MySqlDbType.UInt32,
                IsNullable    = true,
                SourceColumn  = "customer_id",
                SourceVersion = DataRowVersion.Original
            };

            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p2",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "name",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p3",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "address",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p4",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "contact",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p5",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "email",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p6",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "comments",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p7",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "fathers_name",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p8",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "type",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            this._adapter.InsertCommand             = new MySqlCommand();
            this._adapter.InsertCommand.Connection  = this.Connection;
            this._adapter.InsertCommand.CommandText = "INSERT INTO `tbl_customer` (`name`, `address`, `contact`, `email`, `comments`, `fathers_name`, `type`) VALUES (@p1, @p2, @p3, @p4, @p5, @p6, @p7)";
            this._adapter.InsertCommand.CommandType = CommandType.Text;
            parameter = new MySqlParameter {
                ParameterName = "@p1",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "name"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p2",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "address"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p3",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "contact"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p4",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "email"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p5",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "comments"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p6",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "fathers_name"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p7",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "type"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            this._adapter.UpdateCommand             = new MySqlCommand();
            this._adapter.UpdateCommand.Connection  = this.Connection;
            this._adapter.UpdateCommand.CommandText = "UPDATE `tbl_customer` SET `name` = @p1, `address` = @p2, `contact` = @p3, `email` = @p4, `comments` = @p5, `fathers_name` = @p6, `type` = @p7 WHERE ((`customer_id` = @p8) AND (`name` = @p9) AND (`address` = @p10) AND (`contact` = @p11) AND (`email` = @p12) AND (`comments` = @p13) AND (`fathers_name` = @p14) AND (`type` = @p15))";
            this._adapter.UpdateCommand.CommandType = CommandType.Text;
            parameter = new MySqlParameter {
                ParameterName = "@p1",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "name"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p2",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "address"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p3",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "contact"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p4",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "email"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p5",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "comments"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p6",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "fathers_name"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p7",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "type"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p8",
                DbType        = DbType.UInt32,
                MySqlDbType   = MySqlDbType.UInt32,
                IsNullable    = true,
                SourceColumn  = "customer_id",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p9",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "name",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p10",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "address",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p11",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "contact",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p12",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "email",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p13",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "comments",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p14",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "fathers_name",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p15",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "type",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
        }
Пример #16
0
        public void Initialise(DataTableMapping mappings)
        {
            mappings.NotNull(nameof(mappings));

            Mappings = mappings;
        }
        private void InitAdapter()
        {
            this._adapter = new MySqlDataAdapter();
            DataTableMapping mapping = new DataTableMapping {
                SourceTable    = "Table",
                DataSetTable   = "tbl_party_transcation",
                ColumnMappings =
                {
                    {
                        "transcation_id",
                        "transcation_id"
                    },
                    {
                        "party_id",
                        "party_id"
                    },
                    {
                        "date",
                        "date"
                    },
                    {
                        "amount",
                        "amount"
                    },
                    {
                        "description",
                        "description"
                    },
                    {
                        "type",
                        "type"
                    },
                    {
                        "details",
                        "details"
                    },
                    {
                        "invoice_no",
                        "invoice_no"
                    }
                }
            };

            this._adapter.TableMappings.Add(mapping);
            this._adapter.DeleteCommand             = new MySqlCommand();
            this._adapter.DeleteCommand.Connection  = this.Connection;
            this._adapter.DeleteCommand.CommandText = "DELETE FROM `tbl_party_transcation` WHERE ((`transcation_id` = @p1) AND (`party_id` = @p2) AND (`date` = @p3) AND (`amount` = @p4) AND (`description` = @p5) AND (`type` = @p6) AND (`details` = @p7) AND (`invoice_no` = @p8))";
            this._adapter.DeleteCommand.CommandType = CommandType.Text;
            MySqlParameter parameter = new MySqlParameter {
                ParameterName = "@p1",
                DbType        = DbType.UInt32,
                MySqlDbType   = MySqlDbType.UInt32,
                IsNullable    = true,
                SourceColumn  = "transcation_id",
                SourceVersion = DataRowVersion.Original
            };

            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p2",
                DbType        = DbType.UInt32,
                MySqlDbType   = MySqlDbType.UInt32,
                IsNullable    = true,
                SourceColumn  = "party_id",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p3",
                DbType        = DbType.DateTime,
                MySqlDbType   = MySqlDbType.DateTime,
                IsNullable    = true,
                SourceColumn  = "date",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p4",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "amount",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p5",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "description",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p6",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "type",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p7",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "details",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p8",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "invoice_no",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            this._adapter.InsertCommand             = new MySqlCommand();
            this._adapter.InsertCommand.Connection  = this.Connection;
            this._adapter.InsertCommand.CommandText = "INSERT INTO `tbl_party_transcation` (`party_id`, `date`, `amount`, `description`, `type`, `details`, `invoice_no`) VALUES (@p1, @p2, @p3, @p4, @p5, @p6, @p7)";
            this._adapter.InsertCommand.CommandType = CommandType.Text;
            parameter = new MySqlParameter {
                ParameterName = "@p1",
                DbType        = DbType.UInt32,
                MySqlDbType   = MySqlDbType.UInt32,
                IsNullable    = true,
                SourceColumn  = "party_id"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p2",
                DbType        = DbType.DateTime,
                MySqlDbType   = MySqlDbType.DateTime,
                IsNullable    = true,
                SourceColumn  = "date"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p3",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "amount"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p4",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "description"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p5",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "type"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p6",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "details"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p7",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "invoice_no"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            this._adapter.UpdateCommand             = new MySqlCommand();
            this._adapter.UpdateCommand.Connection  = this.Connection;
            this._adapter.UpdateCommand.CommandText = "UPDATE `tbl_party_transcation` SET `party_id` = @p1, `date` = @p2, `amount` = @p3, `description` = @p4, `type` = @p5, `details` = @p6, `invoice_no` = @p7 WHERE ((`transcation_id` = @p8) AND (`party_id` = @p9) AND (`date` = @p10) AND (`amount` = @p11) AND (`description` = @p12) AND (`type` = @p13) AND (`details` = @p14) AND (`invoice_no` = @p15))";
            this._adapter.UpdateCommand.CommandType = CommandType.Text;
            parameter = new MySqlParameter {
                ParameterName = "@p1",
                DbType        = DbType.UInt32,
                MySqlDbType   = MySqlDbType.UInt32,
                IsNullable    = true,
                SourceColumn  = "party_id"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p2",
                DbType        = DbType.DateTime,
                MySqlDbType   = MySqlDbType.DateTime,
                IsNullable    = true,
                SourceColumn  = "date"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p3",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "amount"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p4",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "description"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p5",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "type"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p6",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "details"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p7",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "invoice_no"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p8",
                DbType        = DbType.UInt32,
                MySqlDbType   = MySqlDbType.UInt32,
                IsNullable    = true,
                SourceColumn  = "transcation_id",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p9",
                DbType        = DbType.UInt32,
                MySqlDbType   = MySqlDbType.UInt32,
                IsNullable    = true,
                SourceColumn  = "party_id",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p10",
                DbType        = DbType.DateTime,
                MySqlDbType   = MySqlDbType.DateTime,
                IsNullable    = true,
                SourceColumn  = "date",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p11",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "amount",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p12",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "description",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p13",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "type",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p14",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "details",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p15",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "invoice_no",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
        }
Пример #18
0
        private FbCommand BuildInsertCommand(DataRow row, DataTableMapping tableMapping)
        {
            if (this.commandBuilderBehavior == FbCommandBuilderBehavior.KeyAndTimestampFields &&
                (this.timestampColumnName == null ||
                 this.timestampColumnName.Length == 0))
            {
                throw new InvalidOperationException();
            }

            StringBuilder sql    = new StringBuilder();
            StringBuilder fields = new StringBuilder();
            StringBuilder values = new StringBuilder();

            this.BuildSchemaTable();

            this.CreateCommand(ref this.insertCommand);

            int i = 0;

            foreach (DataRow schemaRow in schemaTable.Rows)
            {
                if (this.IsUpdatable(schemaRow, row, tableMapping))
                {
                    if (fields.Length > 0)
                    {
                        fields.Append(this.separator);
                    }
                    if (values.Length > 0)
                    {
                        values.Append(this.separator);
                    }

                    fields.Append(this.GetQuotedIdentifier(schemaRow["BaseColumnName"]));

                    FbParameter parameter = this.CreateParameter(schemaRow, i, false);

                    values.Append(parameter.ParameterName);

                    if (row != null && tableMapping != null)
                    {
                        DataColumn column = this.GetDataColumn(
                            schemaRow["BaseColumnName"].ToString(),
                            tableMapping,
                            row);

                        if (column != null)
                        {
                            parameter.Value = row[column];
                        }
                    }

                    i++;

                    this.insertCommand.Parameters.Add(parameter);
                }
            }

            sql.AppendFormat(
                CultureInfo.CurrentCulture,
                this.sqlInsert,
                this.GetQuotedIdentifier(tableName),
                fields.ToString(),
                values.ToString());

            this.insertCommand.CommandText = sql.ToString();

            return(this.insertCommand);
        }
Пример #19
0
        public RowUpdatedEventArgs(DataRow dataRow, IDbCommand?command, StatementType statementType, DataTableMapping tableMapping)
        {
            switch (statementType)
            {
            case StatementType.Select:
            case StatementType.Insert:
            case StatementType.Update:
            case StatementType.Delete:
            case StatementType.Batch:
                break;

            default:
                throw ADP.InvalidStatementType(statementType);
            }
            _dataRow       = dataRow;
            _command       = command;
            _statementType = statementType;
            _tableMapping  = tableMapping;
        }
Пример #20
0
        private FbCommand BuildDeleteCommand(DataRow row, DataTableMapping tableMapping)
        {
            if (this.commandBuilderBehavior == FbCommandBuilderBehavior.KeyAndTimestampFields &&
                (this.timestampColumnName == null ||
                 this.timestampColumnName.Length == 0))
            {
                throw new InvalidOperationException();
            }

            StringBuilder sql = new StringBuilder();

            StringBuilder where = new StringBuilder();

            this.BuildSchemaTable();

            if (!this.hasPrimaryKey)
            {
                throw new InvalidOperationException("Dynamic SQL generation for the DeleteCommand is not supported against a SelectCommand that does not return any key column information.");
            }

            this.CreateCommand(ref this.deleteCommand);

            // Build where clausule
            int i = 0;

            foreach (DataRow schemaRow in schemaTable.Rows)
            {
                if (this.IncludedInWhereClause(schemaRow))
                {
                    if (where.Length > 0)
                    {
                        where.Append(" AND ");
                    }

                    string quotedId = this.GetQuotedIdentifier(schemaRow["BaseColumnName"]);

                    // Create parameters for this field
                    FbParameter parameter = this.CreateParameter(schemaRow, i, true);

                    if ((bool)schemaRow["IsKey"])
                    {
                        where.AppendFormat(
                            CultureInfo.CurrentCulture,
                            whereClausule2,
                            quotedId,
                            parameter.ParameterName);
                    }
                    else
                    {
                        if (this.usingCoalesce)
                        {
                            string typeName = TypeHelper.GetDataTypeName((DbDataType)parameter.FbDbType);

                            switch (typeName)
                            {
                            case "VARCHAR":
                            case "CHAR":
                                typeName = String.Format(
                                    CultureInfo.CurrentCulture,
                                    "{0}({1})",
                                    typeName,
                                    schemaRow["ColumnSize"]);
                                break;

                            case "DECIMAL":
                            case "NUMERIC":
                                typeName = String.Format(
                                    CultureInfo.CurrentCulture,
                                    "{0}({1},{2})",
                                    typeName,
                                    schemaRow["NumericPrecision"],
                                    schemaRow["NumericScale"]);
                                break;
                            }

                            where.AppendFormat(
                                CultureInfo.CurrentCulture,
                                whereClausule1,
                                quotedId,
                                parameter.ParameterName,
                                typeName);
                        }
                        else
                        {
                            where.AppendFormat(
                                CultureInfo.CurrentCulture,
                                whereClausule1,
                                quotedId,
                                parameter.ParameterName);
                        }
                    }

                    if (row != null && tableMapping != null)
                    {
                        DataColumn column = this.GetDataColumn(
                            schemaRow["BaseColumnName"].ToString(),
                            tableMapping,
                            row);

                        if (column != null)
                        {
                            parameter.Value = row[column, DataRowVersion.Original];
                        }
                    }

                    this.deleteCommand.Parameters.Add(parameter);

                    i++;
                }
            }

            sql.AppendFormat(
                CultureInfo.CurrentCulture,
                this.sqlDelete,
                this.GetQuotedIdentifier(tableName),
                where.ToString());

            this.deleteCommand.CommandText = sql.ToString();

            return(this.deleteCommand);
        }
        public OleDbRowUpdatedEventArgs(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
            : base(dataRow, command, statementType, tableMapping)

        {
            this.command = (OleDbCommand)command;
        }
Пример #22
0
        private void InitAdapter()
        {
            this._adapter = new SqlDataAdapter();
            DataTableMapping mapping = new DataTableMapping {
                SourceTable  = "Table",
                DataSetTable = "StaffMaster"
            };

            mapping.ColumnMappings.Add("StaffID", "StaffID");
            mapping.ColumnMappings.Add("CompanyID", "CompanyID");
            mapping.ColumnMappings.Add("Email", "Email");
            mapping.ColumnMappings.Add("FirstName", "FirstName");
            mapping.ColumnMappings.Add("LastName", "LastName");
            mapping.ColumnMappings.Add("BillingRate", "BillingRate");
            mapping.ColumnMappings.Add("UserName", "UserName");
            mapping.ColumnMappings.Add("Address1", "Address1");
            mapping.ColumnMappings.Add("Address2", "Address2");
            mapping.ColumnMappings.Add("CountryID", "CountryID");
            mapping.ColumnMappings.Add("StateID", "StateID");
            mapping.ColumnMappings.Add("CityID", "CityID");
            mapping.ColumnMappings.Add("ZipCode", "ZipCode");
            mapping.ColumnMappings.Add("HomePhone", "HomePhone");
            mapping.ColumnMappings.Add("Mobile", "Mobile");
            mapping.ColumnMappings.Add("BussinessPhone", "BussinessPhone");
            mapping.ColumnMappings.Add("Fax", "Fax");
            mapping.ColumnMappings.Add("Notes", "Notes");
            mapping.ColumnMappings.Add("Active", "Active");
            mapping.ColumnMappings.Add("Archived", "Archived");
            mapping.ColumnMappings.Add("Deleted", "Deleted");
            this._adapter.TableMappings.Add(mapping);
            this._adapter.DeleteCommand             = new SqlCommand();
            this._adapter.DeleteCommand.Connection  = this.Connection;
            this._adapter.DeleteCommand.CommandText = "dbo.PR_StaffMaster_Delete";
            this._adapter.DeleteCommand.CommandType = CommandType.StoredProcedure;
            this._adapter.DeleteCommand.Parameters.Add(new SqlParameter("@RETURN_VALUE", SqlDbType.Int, 4, ParameterDirection.ReturnValue, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.DeleteCommand.Parameters.Add(new SqlParameter("@StaffID", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, "StaffID", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand             = new SqlCommand();
            this._adapter.InsertCommand.Connection  = this.Connection;
            this._adapter.InsertCommand.CommandText = "dbo.PR_StaffMaster_Insert";
            this._adapter.InsertCommand.CommandType = CommandType.StoredProcedure;
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@RETURN_VALUE", SqlDbType.Int, 4, ParameterDirection.ReturnValue, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@StaffID", SqlDbType.Int, 4, ParameterDirection.InputOutput, 10, 0, "StaffID", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@CompanyID", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, "CompanyID", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Email", SqlDbType.NVarChar, 50, ParameterDirection.Input, 0, 0, "Email", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@FirstName", SqlDbType.NVarChar, 50, ParameterDirection.Input, 0, 0, "FirstName", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@LastName", SqlDbType.NVarChar, 50, ParameterDirection.Input, 0, 0, "LastName", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@BillingRate", SqlDbType.Decimal, 9, ParameterDirection.Input, 10, 2, "BillingRate", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@UserName", SqlDbType.NVarChar, 50, ParameterDirection.Input, 0, 0, "UserName", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Address1", SqlDbType.NVarChar, 50, ParameterDirection.Input, 0, 0, "Address1", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Address2", SqlDbType.NVarChar, 50, ParameterDirection.Input, 0, 0, "Address2", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@CountryID", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, "CountryID", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@StateID", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, "StateID", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@CityID", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, "CityID", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@ZipCode", SqlDbType.NVarChar, 20, ParameterDirection.Input, 0, 0, "ZipCode", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@HomePhone", SqlDbType.NVarChar, 15, ParameterDirection.Input, 0, 0, "HomePhone", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Mobile", SqlDbType.NVarChar, 10, ParameterDirection.Input, 0, 0, "Mobile", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@BussinessPhone", SqlDbType.NVarChar, 20, ParameterDirection.Input, 0, 0, "BussinessPhone", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Fax", SqlDbType.NVarChar, 20, ParameterDirection.Input, 0, 0, "Fax", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Notes", SqlDbType.NVarChar, 500, ParameterDirection.Input, 0, 0, "Notes", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Active", SqlDbType.Bit, 1, ParameterDirection.Input, 1, 0, "Active", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Archived", SqlDbType.Bit, 1, ParameterDirection.Input, 1, 0, "Archived", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@Deleted", SqlDbType.Bit, 1, ParameterDirection.Input, 1, 0, "Deleted", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand             = new SqlCommand();
            this._adapter.UpdateCommand.Connection  = this.Connection;
            this._adapter.UpdateCommand.CommandText = "dbo.PR_StaffMaster_Update";
            this._adapter.UpdateCommand.CommandType = CommandType.StoredProcedure;
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@RETURN_VALUE", SqlDbType.Int, 4, ParameterDirection.ReturnValue, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@StaffID", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, "StaffID", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@CompanyID", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, "CompanyID", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Email", SqlDbType.NVarChar, 50, ParameterDirection.Input, 0, 0, "Email", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@FirstName", SqlDbType.NVarChar, 50, ParameterDirection.Input, 0, 0, "FirstName", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@LastName", SqlDbType.NVarChar, 50, ParameterDirection.Input, 0, 0, "LastName", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@BillingRate", SqlDbType.Decimal, 9, ParameterDirection.Input, 10, 2, "BillingRate", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@UserName", SqlDbType.NVarChar, 50, ParameterDirection.Input, 0, 0, "UserName", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Address1", SqlDbType.NVarChar, 50, ParameterDirection.Input, 0, 0, "Address1", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Address2", SqlDbType.NVarChar, 50, ParameterDirection.Input, 0, 0, "Address2", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@CountryID", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, "CountryID", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@StateID", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, "StateID", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@CityID", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, "CityID", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@ZipCode", SqlDbType.NVarChar, 20, ParameterDirection.Input, 0, 0, "ZipCode", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@HomePhone", SqlDbType.NVarChar, 15, ParameterDirection.Input, 0, 0, "HomePhone", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Mobile", SqlDbType.NVarChar, 10, ParameterDirection.Input, 0, 0, "Mobile", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@BussinessPhone", SqlDbType.NVarChar, 20, ParameterDirection.Input, 0, 0, "BussinessPhone", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Fax", SqlDbType.NVarChar, 20, ParameterDirection.Input, 0, 0, "Fax", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Notes", SqlDbType.NVarChar, 500, ParameterDirection.Input, 0, 0, "Notes", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Active", SqlDbType.Bit, 1, ParameterDirection.Input, 1, 0, "Active", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Archived", SqlDbType.Bit, 1, ParameterDirection.Input, 1, 0, "Archived", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Deleted", SqlDbType.Bit, 1, ParameterDirection.Input, 1, 0, "Deleted", DataRowVersion.Current, false, null, "", "", ""));
        }
Пример #23
0
        private OracleCommand CreateDeleteCommand(DataRow row, DataTableMapping tableMapping)
        {
            // If no table was found, then we can't do an delete
            if (QuotedTableName == String.Empty)
            {
                return(null);
            }


            CreateNewCommand(ref deleteCommand);

            string        command      = String.Format("DELETE FROM {0} ", QuotedTableName);
            StringBuilder whereClause  = new StringBuilder();
            string        dsColumnName = String.Empty;
            bool          keyFound     = false;
            int           parmIndex    = 1;

            foreach (DataRow schemaRow in dbSchemaTable.Rows)
            {
                if (!IncludedInWhereClause(schemaRow))
                {
                    continue;
                }

                if (whereClause.Length > 0)
                {
                    whereClause.Append(" AND ");
                }

                bool            isKey     = (bool)schemaRow ["IsKey"];
                OracleParameter parameter = null;

                if (!isKey)
                {
                    parameter = deleteCommand.Parameters.Add(CreateParameter(parmIndex++, schemaRow));
                    parameter.SourceVersion = DataRowVersion.Original;

                    dsColumnName = parameter.SourceColumn;
                    if (tableMapping != null &&
                        tableMapping.ColumnMappings.Contains(parameter.SourceColumn))
                    {
                        dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
                    }

                    if (row != null)
                    {
                        parameter.Value = row [dsColumnName, DataRowVersion.Original];
                    }
                    whereClause.Append("(");
                    whereClause.Append(String.Format(clause1, GetQuotedString(parameter.SourceColumn), ":" + parameter.ParameterName));
                    whereClause.Append(" OR ");
                }
                else
                {
                    keyFound = true;
                }

                parameter = deleteCommand.Parameters.Add(CreateParameter(parmIndex++, schemaRow));
                parameter.SourceVersion = DataRowVersion.Original;

                dsColumnName = parameter.SourceColumn;
                if (tableMapping != null &&
                    tableMapping.ColumnMappings.Contains(parameter.SourceColumn))
                {
                    dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
                }

                if (row != null)
                {
                    parameter.Value = row [dsColumnName, DataRowVersion.Original];
                }

                whereClause.Append(String.Format(clause2, GetQuotedString(parameter.SourceColumn), ":" + parameter.ParameterName));

                if (!isKey)
                {
                    whereClause.Append(")");
                }
            }
            if (!keyFound)
            {
                throw new InvalidOperationException("Dynamic SQL generation for the DeleteCommand is not supported against a SelectCommand that does not return any key column information.");
            }

            // We're all done, so bring it on home
            string sql = String.Format("{0} WHERE ( {1} )", command, whereClause.ToString());

            deleteCommand.CommandText = sql;
            return(deleteCommand);
        }
Пример #24
0
        private void InitAdapter()
        {
            this._adapter = new SqlDataAdapter();
            DataTableMapping mapping = new DataTableMapping {
                SourceTable  = "Table",
                DataSetTable = "CompanyPackageDetails"
            };

            mapping.ColumnMappings.Add("CompanyPackageID", "CompanyPackageID");
            mapping.ColumnMappings.Add("CompanyID", "CompanyID");
            mapping.ColumnMappings.Add("PackageID", "PackageID");
            mapping.ColumnMappings.Add("PackageStartDate", "PackageStartDate");
            mapping.ColumnMappings.Add("PackageEndDate", "PackageEndDate");
            mapping.ColumnMappings.Add("PackageMonthlyAmount", "PackageMonthlyAmount");
            mapping.ColumnMappings.Add("PackageYearlyAmount", "PackageYearlyAmount");
            mapping.ColumnMappings.Add("PackagePaid", "PackagePaid");
            mapping.ColumnMappings.Add("PackagePaidAmount", "PackagePaidAmount");
            mapping.ColumnMappings.Add("PackagePaymentTransDetail", "PackagePaymentTransDetail");
            mapping.ColumnMappings.Add("PackagePaymentTransDate", "PackagePaymentTransDate");
            mapping.ColumnMappings.Add("PackageAssignDate", "PackageAssignDate");
            mapping.ColumnMappings.Add("ActivePackage", "ActivePackage");
            this._adapter.TableMappings.Add(mapping);
            this._adapter.DeleteCommand             = new SqlCommand();
            this._adapter.DeleteCommand.Connection  = this.Connection;
            this._adapter.DeleteCommand.CommandText = "dbo.PR_CompanyPackageDetails_Delete";
            this._adapter.DeleteCommand.CommandType = CommandType.StoredProcedure;
            this._adapter.DeleteCommand.Parameters.Add(new SqlParameter("@RETURN_VALUE", SqlDbType.Int, 4, ParameterDirection.ReturnValue, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.DeleteCommand.Parameters.Add(new SqlParameter("@CompanyPackageID", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, "CompanyPackageID", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand             = new SqlCommand();
            this._adapter.InsertCommand.Connection  = this.Connection;
            this._adapter.InsertCommand.CommandText = "dbo.PR_CompanyPackageDetails_Insert";
            this._adapter.InsertCommand.CommandType = CommandType.StoredProcedure;
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@RETURN_VALUE", SqlDbType.Int, 4, ParameterDirection.ReturnValue, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@CompanyPackageID", SqlDbType.Int, 4, ParameterDirection.InputOutput, 10, 0, "CompanyPackageID", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@CompanyID", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, "CompanyID", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@PackageID", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, "PackageID", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@PackageStartDate", SqlDbType.SmallDateTime, 4, ParameterDirection.Input, 0x10, 0, "PackageStartDate", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@PackageEndDate", SqlDbType.SmallDateTime, 4, ParameterDirection.Input, 0x10, 0, "PackageEndDate", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@PackageMonthlyAmount", SqlDbType.Money, 8, ParameterDirection.Input, 0x13, 4, "PackageMonthlyAmount", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@PackageYearlyAmount", SqlDbType.Money, 8, ParameterDirection.Input, 0x13, 4, "PackageYearlyAmount", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@PackagePaid", SqlDbType.Bit, 1, ParameterDirection.Input, 1, 0, "PackagePaid", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@PackagePaidAmount", SqlDbType.Money, 8, ParameterDirection.Input, 0x13, 4, "PackagePaidAmount", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@PackagePaymentTransDetail", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "PackagePaymentTransDetail", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@PackagePaymentTransDate", SqlDbType.SmallDateTime, 4, ParameterDirection.Input, 0x10, 0, "PackagePaymentTransDate", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@PackageAssignDate", SqlDbType.SmallDateTime, 4, ParameterDirection.Input, 0x10, 0, "PackageAssignDate", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@ActivePackage", SqlDbType.Bit, 1, ParameterDirection.Input, 1, 0, "ActivePackage", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand             = new SqlCommand();
            this._adapter.UpdateCommand.Connection  = this.Connection;
            this._adapter.UpdateCommand.CommandText = "dbo.PR_CompanyPackageDetails_Update";
            this._adapter.UpdateCommand.CommandType = CommandType.StoredProcedure;
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@RETURN_VALUE", SqlDbType.Int, 4, ParameterDirection.ReturnValue, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@CompanyPackageID", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, "CompanyPackageID", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@CompanyID", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, "CompanyID", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@PackageID", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, "PackageID", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@PackageStartDate", SqlDbType.SmallDateTime, 4, ParameterDirection.Input, 0x10, 0, "PackageStartDate", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@PackageEndDate", SqlDbType.SmallDateTime, 4, ParameterDirection.Input, 0x10, 0, "PackageEndDate", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@PackageMonthlyAmount", SqlDbType.Money, 8, ParameterDirection.Input, 0x13, 4, "PackageMonthlyAmount", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@PackageYearlyAmount", SqlDbType.Money, 8, ParameterDirection.Input, 0x13, 4, "PackageYearlyAmount", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@PackagePaid", SqlDbType.Bit, 1, ParameterDirection.Input, 1, 0, "PackagePaid", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@PackagePaidAmount", SqlDbType.Money, 8, ParameterDirection.Input, 0x13, 4, "PackagePaidAmount", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@PackagePaymentTransDetail", SqlDbType.NVarChar, 200, ParameterDirection.Input, 0, 0, "PackagePaymentTransDetail", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@PackagePaymentTransDate", SqlDbType.SmallDateTime, 4, ParameterDirection.Input, 0x10, 0, "PackagePaymentTransDate", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@PackageAssignDate", SqlDbType.SmallDateTime, 4, ParameterDirection.Input, 0x10, 0, "PackageAssignDate", DataRowVersion.Current, false, null, "", "", ""));
            this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@ActivePackage", SqlDbType.Bit, 1, ParameterDirection.Input, 1, 0, "ActivePackage", DataRowVersion.Current, false, null, "", "", ""));
        }
Пример #25
0
        static void Main(string[] args)
        {
            DataSet dsUsers = new DataSet("Users");

            try
            {
                OleDbConnection dbConn =
                    new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" +
                                        "Password=;User ID=Admin;Data Source=db.mdb");

                // Create a data adapter to retrieve records from db
                OleDbDataAdapter daUsers =
                    new OleDbDataAdapter("SELECT ID,fn,ln,cty,st" +
                                         " FROM tabUsers", dbConn);

                // Define each column to map
                DataColumnMapping dcmUserID =
                    new DataColumnMapping("ID", "UserID");
                DataColumnMapping dcmFirstName =
                    new DataColumnMapping("fn", "FirstName");
                DataColumnMapping dcmLastName =
                    new DataColumnMapping("ln", "LastName");
                DataColumnMapping dcmCity =
                    new DataColumnMapping("cty", "City");
                DataColumnMapping dcmState =
                    new DataColumnMapping("st", "State");
                // Define the table containing the mapped columns
                DataTableMapping dtmUsers =
                    new DataTableMapping("Table", "User");
                dtmUsers.ColumnMappings.Add(dcmUserID);
                dtmUsers.ColumnMappings.Add(dcmFirstName);
                dtmUsers.ColumnMappings.Add(dcmLastName);
                dtmUsers.ColumnMappings.Add(dcmCity);
                dtmUsers.ColumnMappings.Add(dcmState);

                // Activate the mapping mechanism
                daUsers.TableMappings.Add(dtmUsers);

                // Fill the dataset
                daUsers.Fill(dsUsers);

                DataColumn[] dcaKey = { dsUsers.Tables[0].Columns["UserID"] };
                dsUsers.Tables[0].PrimaryKey = dcaKey;

                // Declare a command builder to create SQL instructions
                // to create and update records.
                OleDbCommandBuilder cb = new OleDbCommandBuilder(daUsers);

                // Update an existing record in the DataSet
                DataRow r = dsUsers.Tables[0].Rows.Find(8);

                if (r != null)
                {
                    r["FirstName"] = "Venus";
                    r["LastName"]  = "Williams";
                    r["City"]      = "Houston";
                    r["State"]     = "Texas";

                    // Update the record in the database
                    daUsers.Update(dsUsers.GetChanges());

                    // Align in-memory data with the data source ones
                    dsUsers.AcceptChanges();

                    // Print success message
                    Console.WriteLine("The record has been updated " +
                                      "successfully.");
                }
                else
                {
                    Console.WriteLine("No record found...");
                }
            }
            catch (System.Exception ex)
            {
                // Reject DataSet changes
                dsUsers.RejectChanges();

                // An error occurred. Show the error message
                Console.WriteLine(ex.Message);
            }
        }
Пример #26
0
 // <Snippet1>
 public void CreateDataTableMapping()
 {
     DataTableMapping mapping =
         new DataTableMapping("Categories", "DataCategories");
 }
Пример #27
0
        private void InitAdapter()
        {
            this._adapter = new MySqlDataAdapter();
            DataTableMapping mapping = new DataTableMapping {
                SourceTable    = "Table",
                DataSetTable   = "tbl_expences",
                ColumnMappings =
                {
                    {
                        "expences_id",
                        "expences_id"
                    },
                    {
                        "description",
                        "description"
                    },
                    {
                        "date",
                        "date"
                    },
                    {
                        "userId",
                        "userId"
                    },
                    {
                        "amount",
                        "amount"
                    },
                    {
                        "name",
                        "name"
                    }
                }
            };

            this._adapter.TableMappings.Add(mapping);
            this._adapter.DeleteCommand             = new MySqlCommand();
            this._adapter.DeleteCommand.Connection  = this.Connection;
            this._adapter.DeleteCommand.CommandText = "DELETE FROM `tbl_expences` WHERE ((`expences_id` = @p1) AND (`description` = @p2) AND (`date` = @p3) AND (`userId` = @p4) AND (`amount` = @p5) AND (`name` = @p6))";
            this._adapter.DeleteCommand.CommandType = CommandType.Text;
            MySqlParameter parameter = new MySqlParameter {
                ParameterName = "@p1",
                DbType        = DbType.UInt32,
                MySqlDbType   = MySqlDbType.UInt32,
                IsNullable    = true,
                SourceColumn  = "expences_id",
                SourceVersion = DataRowVersion.Original
            };

            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p2",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "description",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p3",
                DbType        = DbType.Date,
                MySqlDbType   = MySqlDbType.Date,
                IsNullable    = true,
                SourceColumn  = "date",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p4",
                DbType        = DbType.UInt32,
                MySqlDbType   = MySqlDbType.UInt32,
                IsNullable    = true,
                SourceColumn  = "userId",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p5",
                DbType        = DbType.UInt32,
                MySqlDbType   = MySqlDbType.UInt32,
                IsNullable    = true,
                SourceColumn  = "amount",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p6",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "name",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            this._adapter.InsertCommand             = new MySqlCommand();
            this._adapter.InsertCommand.Connection  = this.Connection;
            this._adapter.InsertCommand.CommandText = "INSERT INTO `tbl_expences` (`description`, `date`, `userId`, `amount`, `name`) VALUES (@p1, @p2, @p3, @p4, @p5)";
            this._adapter.InsertCommand.CommandType = CommandType.Text;
            parameter = new MySqlParameter {
                ParameterName = "@p1",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "description"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p2",
                DbType        = DbType.Date,
                MySqlDbType   = MySqlDbType.Date,
                IsNullable    = true,
                SourceColumn  = "date"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p3",
                DbType        = DbType.UInt32,
                MySqlDbType   = MySqlDbType.UInt32,
                IsNullable    = true,
                SourceColumn  = "userId"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p4",
                DbType        = DbType.UInt32,
                MySqlDbType   = MySqlDbType.UInt32,
                IsNullable    = true,
                SourceColumn  = "amount"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p5",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "name"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            this._adapter.UpdateCommand             = new MySqlCommand();
            this._adapter.UpdateCommand.Connection  = this.Connection;
            this._adapter.UpdateCommand.CommandText = "UPDATE `tbl_expences` SET `description` = @p1, `date` = @p2, `userId` = @p3, `amount` = @p4, `name` = @p5 WHERE ((`expences_id` = @p6) AND (`description` = @p7) AND (`date` = @p8) AND (`userId` = @p9) AND (`amount` = @p10) AND (`name` = @p11))";
            this._adapter.UpdateCommand.CommandType = CommandType.Text;
            parameter = new MySqlParameter {
                ParameterName = "@p1",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "description"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p2",
                DbType        = DbType.Date,
                MySqlDbType   = MySqlDbType.Date,
                IsNullable    = true,
                SourceColumn  = "date"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p3",
                DbType        = DbType.UInt32,
                MySqlDbType   = MySqlDbType.UInt32,
                IsNullable    = true,
                SourceColumn  = "userId"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p4",
                DbType        = DbType.UInt32,
                MySqlDbType   = MySqlDbType.UInt32,
                IsNullable    = true,
                SourceColumn  = "amount"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p5",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "name"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p6",
                DbType        = DbType.UInt32,
                MySqlDbType   = MySqlDbType.UInt32,
                IsNullable    = true,
                SourceColumn  = "expences_id",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p7",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "description",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p8",
                DbType        = DbType.Date,
                MySqlDbType   = MySqlDbType.Date,
                IsNullable    = true,
                SourceColumn  = "date",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p9",
                DbType        = DbType.UInt32,
                MySqlDbType   = MySqlDbType.UInt32,
                IsNullable    = true,
                SourceColumn  = "userId",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p10",
                DbType        = DbType.UInt32,
                MySqlDbType   = MySqlDbType.UInt32,
                IsNullable    = true,
                SourceColumn  = "amount",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p11",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "name",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
        }
Пример #28
0
 protected override RowUpdatingEventArgs CreateRowUpdatingEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
 {
     // 04/24/2006 Paul.  I don't like seeing the unreachable code warning.
     //throw new NotImplementedException();
     return(null);
 }
Пример #29
0
 public NpgsqlRowUpdatedEventArgs(DataRow dataRow, IDbCommand command, StatementType statementType,
                                  DataTableMapping tableMapping)
     : base(dataRow, command, statementType, tableMapping)
 {
 }
Пример #30
0
        private void InitAdapter()
        {
            this._adapter = new MySqlDataAdapter();
            DataTableMapping mapping = new DataTableMapping {
                SourceTable    = "Table",
                DataSetTable   = "tbl_salary",
                ColumnMappings =
                {
                    {
                        "employeeId",
                        "employeeId"
                    },
                    {
                        "salary",
                        "salary"
                    },
                    {
                        "month",
                        "month"
                    },
                    {
                        "payment",
                        "payment"
                    },
                    {
                        "loan",
                        "loan"
                    },
                    {
                        "advance",
                        "advance"
                    },
                    {
                        "deduction",
                        "deduction"
                    },
                    {
                        "net_salary",
                        "net_salary"
                    },
                    {
                        "expences_id",
                        "expences_id"
                    }
                }
            };

            this._adapter.TableMappings.Add(mapping);
            this._adapter.DeleteCommand             = new MySqlCommand();
            this._adapter.DeleteCommand.Connection  = this.Connection;
            this._adapter.DeleteCommand.CommandText = "DELETE FROM `tbl_salary` WHERE ((`employeeId` = @p1) AND (`salary` = @p2) AND (`month` = @p3) AND (`payment` = @p4) AND (`loan` = @p5) AND (`advance` = @p6) AND (`deduction` = @p7) AND (`net_salary` = @p8) AND (`expences_id` = @p9))";
            this._adapter.DeleteCommand.CommandType = CommandType.Text;
            MySqlParameter parameter = new MySqlParameter {
                ParameterName = "@p1",
                DbType        = DbType.UInt32,
                MySqlDbType   = MySqlDbType.UInt32,
                IsNullable    = true,
                SourceColumn  = "employeeId",
                SourceVersion = DataRowVersion.Original
            };

            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p2",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "salary",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p3",
                DbType        = DbType.Date,
                MySqlDbType   = MySqlDbType.Date,
                IsNullable    = true,
                SourceColumn  = "month",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p4",
                DbType        = DbType.Date,
                MySqlDbType   = MySqlDbType.Date,
                IsNullable    = true,
                SourceColumn  = "payment",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p5",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "loan",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p6",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "advance",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p7",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "deduction",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p8",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "net_salary",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p9",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "expences_id",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.DeleteCommand.Parameters.Add(parameter);
            this._adapter.InsertCommand             = new MySqlCommand();
            this._adapter.InsertCommand.Connection  = this.Connection;
            this._adapter.InsertCommand.CommandText = "INSERT INTO `tbl_salary` (`employeeId`, `salary`, `month`, `payment`, `loan`, `advance`, `deduction`, `net_salary`, `expences_id`) VALUES (@p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9)";
            this._adapter.InsertCommand.CommandType = CommandType.Text;
            parameter = new MySqlParameter {
                ParameterName = "@p1",
                DbType        = DbType.UInt32,
                MySqlDbType   = MySqlDbType.UInt32,
                IsNullable    = true,
                SourceColumn  = "employeeId"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p2",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "salary"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p3",
                DbType        = DbType.Date,
                MySqlDbType   = MySqlDbType.Date,
                IsNullable    = true,
                SourceColumn  = "month"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p4",
                DbType        = DbType.Date,
                MySqlDbType   = MySqlDbType.Date,
                IsNullable    = true,
                SourceColumn  = "payment"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p5",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "loan"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p6",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "advance"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p7",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "deduction"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p8",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "net_salary"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p9",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "expences_id"
            };
            this._adapter.InsertCommand.Parameters.Add(parameter);
            this._adapter.UpdateCommand             = new MySqlCommand();
            this._adapter.UpdateCommand.Connection  = this.Connection;
            this._adapter.UpdateCommand.CommandText = "UPDATE `tbl_salary` SET `employeeId` = @p1, `salary` = @p2, `month` = @p3, `payment` = @p4, `loan` = @p5, `advance` = @p6, `deduction` = @p7, `net_salary` = @p8, `expences_id` = @p9 WHERE ((`employeeId` = @p10) AND (`salary` = @p11) AND (`month` = @p12) AND (`payment` = @p13) AND (`loan` = @p14) AND (`advance` = @p15) AND (`deduction` = @p16) AND (`net_salary` = @p17) AND (`expences_id` = @p18))";
            this._adapter.UpdateCommand.CommandType = CommandType.Text;
            parameter = new MySqlParameter {
                ParameterName = "@p1",
                DbType        = DbType.UInt32,
                MySqlDbType   = MySqlDbType.UInt32,
                IsNullable    = true,
                SourceColumn  = "employeeId"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p2",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "salary"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p3",
                DbType        = DbType.Date,
                MySqlDbType   = MySqlDbType.Date,
                IsNullable    = true,
                SourceColumn  = "month"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p4",
                DbType        = DbType.Date,
                MySqlDbType   = MySqlDbType.Date,
                IsNullable    = true,
                SourceColumn  = "payment"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p5",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "loan"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p6",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "advance"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p7",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "deduction"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p8",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "net_salary"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p9",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "expences_id"
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p10",
                DbType        = DbType.UInt32,
                MySqlDbType   = MySqlDbType.UInt32,
                IsNullable    = true,
                SourceColumn  = "employeeId",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p11",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "salary",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p12",
                DbType        = DbType.Date,
                MySqlDbType   = MySqlDbType.Date,
                IsNullable    = true,
                SourceColumn  = "month",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p13",
                DbType        = DbType.Date,
                MySqlDbType   = MySqlDbType.Date,
                IsNullable    = true,
                SourceColumn  = "payment",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p14",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "loan",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p15",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "advance",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p16",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "deduction",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p17",
                DbType        = DbType.Double,
                MySqlDbType   = MySqlDbType.Double,
                IsNullable    = true,
                SourceColumn  = "net_salary",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
            parameter = new MySqlParameter {
                ParameterName = "@p18",
                DbType        = DbType.String,
                MySqlDbType   = MySqlDbType.VarChar,
                IsNullable    = true,
                SourceColumn  = "expences_id",
                SourceVersion = DataRowVersion.Original
            };
            this._adapter.UpdateCommand.Parameters.Add(parameter);
        }
Пример #31
0
 /// <summary>
 /// Async version of Update
 /// </summary>
 /// <param name="dataRows">DataRow[] to use</param>
 /// <param name="tableMapping">Data Table Mapping</param>
 /// <returns>int</returns>
 public Task <int> UpdateAsync(DataRow[] dataRows, DataTableMapping tableMapping)
 {
     return(UpdateAsync(dataRows, tableMapping, CancellationToken.None));
 }
Пример #32
0
 /// <summary>
 /// 由子类利用相应Adapter执行command并传回Dataset
 /// </summary>
 /// <param name="command"></param>
 /// <param name="mapping"></param>
 /// <param name="result"></param>
 /// <returns></returns>
 public abstract int ExecuteDataSet(DbCommand command, DataTableMapping mapping, ref DataSet result);
Пример #33
0
 public NpgsqlRowUpdatingEventArgs(DataRow dataRow, IDbCommand command, StatementType statementType,
                                   DataTableMapping tableMapping)
     : base(dataRow, command, statementType, tableMapping)
 {
 }
Пример #34
0
 protected override RowUpdatedEventArgs CreateRowUpdatedEvent(DataRow dataRow, IDbCommand?command, StatementType statementType, DataTableMapping tableMapping)
 {
     return(new OleDbRowUpdatedEventArgs(dataRow, command, statementType, tableMapping));
 }