How to update a table using SqlAdapter.Update, which does not have a primary key

I have SqlDataAdapterone in which I am updating DataRow.

I have an exception

Dynamic SQL generation for UpdateCommand is not supported with SelectCommand, which does not return key column information

Error if I put the primary key in the table.

But I do not want to insert a primary key into it.

var dataAdapter = new SqlDataAdapter();
var updatedRows = Getting some row ...
dataAdapter.Update(updatedRows);
+4
source share
1 answer

Without a primary key, you cannot rely on SqlCommandBuilder to create insert / update / delete commands for you.

SqlDataAdapter , InsertCommand, UpdateCommand, DeleteCommand.

: https://msdn.microsoft.com/en-us/library/ms971491.aspx

: . UPDATE sql, 1 DataRow. .

+1

All Articles