473,320 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

UPDATE into dataset but no INSERT

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
3 1448
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Yog | last post by:
I have a datagrid binded to a dataset and once the user updates the grid my dataset is reflected. When i wanted to save the data to tables, however i needed to insert this data into another...
4
by: Oscar Thornell | last post by:
Hi, I have a relativley large/complex typed dataset that contains 7-8 tables and some supporting relational tables (lookups) for many-to-many relations. A good exampel would be a dataset that...
0
by: M. David Johnson | last post by:
I cannot get my OleDbDataAdapter to update my database table from my local dataset table. The Knowledge Base doesn't seem to help - see item 10 below. I have a Microsoft Access 2000 database...
15
by: graham | last post by:
Hi all, <bitching and moaning section> I am asking for any help I can get here... I am at the end of my tether... I don;t consider myself a genius in any way whatsoever, but I do believe I have...
13
by: =?Utf-8?B?VmVybm9uIFBlcHBlcnM=?= | last post by:
I am using VS2005. I created a Windows Appication project. Inside the Server Explorer, I created a new SQLExpress database, and then created a new table. I added the rows, making my first row an...
8
by: Ornette | last post by:
Hello, I have a stored procedure which generates some values in the table. When I use update() how to populate the dataset with theses values ? For the moment I use output parameter but it...
0
by: Hurricane | last post by:
I have my SQL database with a table that I am trying to have a gridview dislay with inline editing. It seems as if the dataset does not generate the apropriate update query, and therefore...
6
by: Tark Siala | last post by:
hi i'm using VS.NET 2005 +SP1 C#, and i connect access database by ADO.NET 2.0. i'm using Dataset to (insert,update,delete) and in get data i use (Datareader), but my problem when i do this: 1 -...
13
by: Terry Olsen | last post by:
I'm using OleDb to connect with an Access Database. I have anywhere from 10 to over 100 records that I need to either INSERT if the PK doesn't exist or UPDATE if the PK does exist, all in a single...
2
by: BobLewiston | last post by:
Some of you may have seen my earlier thread “PasswordHash NULL problem”. I’ve started a new thread because investigation has shown that the problem is actually quite different than I previously...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.