UPDATE into dataset but no INSERT

J

Jo Segers

Hi,

Is it possible to allow updates in a dataset via a datagrid but no
inserts? Can somebody explain how?

Thanks in advance,

Jo Segers.
 
G

Guest

There are a couple of ways to take charge. The first is to look at the rows
in the DataSet and focus on changed rows and not new rows. This puts the onus
on the code.

The other method is to handle this in your database. There are two ways.

If you create a stored procedure to handle the INSERT/UPDATE, the only
difference between the two is one has the primary key filled in and the other
does not (if you are creating GUIDs in code, this will not work, of course).
Ignore those items without the primary key. Another variation (when you are
creating the key) is to check for the pre-existence of this key and pitch any
new items.

You can also create a trigger that does not allow inserts at all, but this
will be across all applications, so it is probably not useful.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
C

Chris Dunaway

The DataGridView control has an AllowUserToAdd property that you can
set to false. I'm not sure if the regular datagrid has a similar
property or not.
 
J

Jo Segers

Cowboy (Gregory A. Beamer) - MVP schreef:
There are a couple of ways to take charge. The first is to look at the rows
in the DataSet and focus on changed rows and not new rows. This puts the onus
on the code.

The other method is to handle this in your database. There are two ways.

If you create a stored procedure to handle the INSERT/UPDATE, the only
difference between the two is one has the primary key filled in and the other
does not (if you are creating GUIDs in code, this will not work, of course).
Ignore those items without the primary key. Another variation (when you are
creating the key) is to check for the pre-existence of this key and pitch any
new items.

You can also create a trigger that does not allow inserts at all, but this
will be across all applications, so it is probably not useful.
Thank you for your answer. I got it to work now.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top