By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,465 Members | 1,497 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,465 IT Pros & Developers. It's quick & easy.

UPDATE into dataset but no INSERT

P: n/a
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.
Mar 28 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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!
***************************
"Jo Segers" wrote:
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.

Mar 28 '06 #2

P: n/a
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.

Mar 28 '06 #3

P: n/a
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.
Apr 7 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.