public new NpgsqlCommand GetInsertCommand(bool useColumnsForParameterNames) { NpgsqlCommand cmd = (NpgsqlCommand) base.GetInsertCommand(useColumnsForParameterNames); cmd.UpdatedRowSource = UpdateRowSource.None; return cmd; }
/// <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; } }