Npgsql.NpgsqlCommandBuilder.GetDeleteCommand C# (CSharp) Method

GetDeleteCommand() public method

Gets the automatically generated System.Data.Common.DbCommand object required to perform deletions at the data source.
public GetDeleteCommand ( ) : NpgsqlCommand
return NpgsqlCommand
        public new NpgsqlCommand GetDeleteCommand()
        {
            return GetDeleteCommand(false);
        }

Same methods

NpgsqlCommandBuilder::GetDeleteCommand ( bool useColumnsForParameterNames ) : 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;
              }
        }