Laden...

Forenbeiträge von firealarm Ingesamt 1 Beiträge

18.10.2007 - 17:03 Uhr

Hallo,

benutze ebenfalls die ProviderFactory und nutze als DB-Provider Npgsql.Net.

Alles klappt wunderbar, nur mit dem DBCommandBuilder habe ich Probleme:

habe alles identisch wie in deinem SourceCode oben:


// create Database command
DbCommand command = dbconf.ProviderFactory.CreateCommand();
command.Connection = CurrentConnection;
command.CommandType = CommandType.Text;
command.CommandText = query.ToString();

// create Dataadapter               
DbDataAdapter adapter = dbconf.ProviderFactory.CreateDataAdapter();
adapter.SelectCommand = command;
adapter.AcceptChangesDuringUpdate = true;


// create Commandbuilder
//DbCommandBuilder builder = dbconf.ProviderFactory.CreateCommandBuilder();
//builder.ConflictOption = ConflictOption.CompareAllSearchableValues;
//builder.DataAdapter = adapter;

Npgsql.NpgsqlCommandBuilder builder = new Npgsql.NpgsqlCommandBuilder();
builder.ConflictOption = ConflictOption.CompareAllSearchableValues;
builder.DataAdapter = adapter as Npgsql.NpgsqlDataAdapter;

// update Database
adapter.Update( a_DataTable );

Ich bekomme aber immer die Fehlermeldung, wenn ich den DbCommandBuilder benutze: "Aktualisieren erfordert einen gültigen InsertCommand, wenn eine DataRow-Auflistung mit neuen Zeilen weitergegeben wird."

Wenn den NpgsqlCommandBuilder benutze, läuft es.
DbCommandBuilder ist auch von Typ NpgsqlCommandBuilder. Könnt ihr mir helfen???