Npgsql.NpgsqlCommandBuilder.GetDeleteCommand C# (CSharp) Method

GetDeleteCommand() public method

Gets the automatically generated NpgsqlCommand object required to perform deletions at the data source, optionally using columns for parameter names.
public GetDeleteCommand ( bool useColumnsForParameterNames ) : NpgsqlCommand
useColumnsForParameterNames bool /// If true, generate parameter names matching column names, if possible. /// If false, generate @p1, @p2, and so on. ///
return NpgsqlCommand
        public new NpgsqlCommand GetDeleteCommand(bool useColumnsForParameterNames)
        {
            NpgsqlCommand cmd = (NpgsqlCommand) base.GetDeleteCommand(useColumnsForParameterNames);
            cmd.UpdatedRowSource = UpdateRowSource.None;
            return cmd;
        }

Same methods

NpgsqlCommandBuilder::GetDeleteCommand ( ) : NpgsqlCommand

Usage Example

示例#1
0
        /// <summary>
        /// DataSet ---NpgsqlDataAdapter ---Database
        /// </summary>
        public NpgsqlDataAdapter GetDataAdapter(string strSQL)
        {
            // Use NpgsqlCommandBuilder and SelectCommand--->Auto generate InsertCommand UpdateCommand DeleteCommand
              try
              {
              m_gCommnd.CommandText = strSQL;
              NpgsqlDataAdapter dataAdapter = new NpgsqlDataAdapter(m_gCommnd);//associate
              //InsertCommand  UpdateCommand DeleteCommand SelectCommand = m_sqlCommand;

              // Initialize the InsertCommand UpdateCommand DeleteCommand of NpgsqlDataAdapter by NpgsqlCommandBuilder.
              NpgsqlCommandBuilder cb = new NpgsqlCommandBuilder(dataAdapter);
              dataAdapter.InsertCommand = cb.GetInsertCommand();
              dataAdapter.UpdateCommand = cb.GetUpdateCommand();
              dataAdapter.DeleteCommand = cb.GetDeleteCommand();
              return dataAdapter;
              }
              catch (System.Exception ex)
              {
              MessageBox.Show(ex.ToString());
              return null;
              }
        }