public static int Save(DataSet ds, string tableName, string primaryKeyName, bool retrieveAutoIncrementPK, IDbDataAdapter dbAdapter) { DataSet changes = ds.GetChanges(); NpgsqlTransaction transact = Connection.BeginTransaction(); int RowsUpdated = 0; if (changes != null) { if (retrieveAutoIncrementPK) ((NpgsqlDataAdapter)dbAdapter).RowUpdated += delegate(object sender, NpgsqlRowUpdatedEventArgs args) { if (args.StatementType == StatementType.Insert) { if (args.Row[primaryKeyName].ToString() == "") args.Row[primaryKeyName] = SequenceCurrentValue( args.Row.Table.TableName, primaryKeyName); } }; try { RowsUpdated = dbAdapter.Update(changes); } catch (NpgsqlException e) { transact.Rollback(); throw e; } } transact.Commit(); if (changes != null) ds.Merge(changes, false, MissingSchemaAction.Error); ds.AcceptChanges(); foreach (DataRow dr in ds.Tables[tableName].Rows) if (dr[dr.Table.PrimaryKey[0].ColumnName].GetType() == typeof(System.DBNull)) dr.Delete(); ds.AcceptChanges(); return RowsUpdated; }> ... it may be something else that's causing it to not work, but off the top of my head I have no ideas.
foreach (GridColumnDataSet.GridColumnsRow dr in dataGridColumns.GridColumns) { string columnName = dr.controlsrc.Trim(); DataGridColumnStyle colStyle; if (table.Columns[columnName].DataType.Name == "Boolean") { colStyle = new DataGridBoolColumn(); ((DataGridBoolColumn)colStyle).AllowNull = false; } else { colStyle = new DataGridTextBoxColumn(); if (table.Columns[columnName].DataType.Name == "Decimal") colStyle.Alignment = HorizontalAlignment.Right; } colStyle.MappingName = dr.controlsrc.Trim(); colStyle.HeaderText = dr.veerunimi.Trim(); colStyle.Width = dr.width; tableStyle.GridColumnStyles.Add(colStyle); } TableStyles.Add(tableStyle); DataSource = table;> (and ... are we talking about DataGrid or the new DataGridView? I tried this with the old DataGrid).