473,320 Members | 1,939 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.

Cannot delete a record after adding in a DataGrid

HS1
Hello all

I have a DataGrid1 presenting records of a table ("clients") in a Access
Database through a DataSet (ds) using DataAdapter (da1) and buttons "add",
"save" and"delete" buttons with the code bellow:

------------------
a button "Add":
Private Sub Button_Add_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button_Add.Click

Me.BindingContext(ds, "Clients").AddNew()

a button "Save":
---------
Private Sub Button_Save_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button_Save.Click

Me.BindingContext(ds, "Clients").EndCurrentEdit()

da1.Update(ds, "Clients")

-------

a button "Delete":

Private Sub Button_Delete_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button_Delete.Click
If MsgBoxResult.Yes = _

MessageBox.Show(" Do you really want to delete this item", "Confirm dialog
box", MessageBoxButtons.YesNoCancel) Then

Dim pos As Integer

pos = Me.BindingContext(DataGrid1.DataSource, "Clients").Position()

Me.BindingContext(DataGrid1.DataSource, "Clients").RemoveAt(pos)

da1.Update(ds, "Clients")

End If

---------------------------------------------------------------

You can see that, I already used function da1.Update(ds, "Clients") after
"Save". However, when I add new record, save that record and then click
"delete" to delete this record, there is error " Concurrency violation: the
DeleteCommand affected 0 records."

When I exit the application then run again, I can delete that record. I do
not know why. Could you please help

Thank you

SHoa

Nov 21 '05 #1
0 1241

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Calvin Lai | last post by:
Hi all, Does anyone know how I could add a confirm (client side) feature on those Delete Linkbutton in DataGrid? Thanks,
3
by: vcornjamb | last post by:
Hello, I am developing a web form that contains some buttons and a data grid which has as its last column link buttons that will delete the data associated with that row. Everything works fine,...
6
by: JenHu | last post by:
Hi experts, I want to add a delete button in my datagrid, and before it deletes from database, I want to have a confirm dialog box for this deletion. I am entry level to the vb.net, and don't...
4
by: DrData | last post by:
I'm working on an ASP.Net application written in C#. On one page, there are several datagrid controls used to display, edit and delete detail records relating to the master record also displayed on...
0
by: HS1 | last post by:
Hello all I have a DataGrid1 presenting records of a table ("clients") in a Access Database through a DataSet (ds) using DataAdapter (da1) and buttons "add", "save" and"delete" buttons with the...
5
by: Jeff User | last post by:
Hello ..NET 1.1, VS 2003, C# & asp.net I have tried to follow msdn instructions and samples but I can not get an event to fire for this button on the datagrid. There has to be something obvious...
4
by: drakuu | last post by:
Hello there, I have DataGrid with some records and I would like to edit it right in the datagrid using the built in commands. I can't figure out a way to pass to the SQL query the record ID...
10
by: amiga500 | last post by:
Hello, I have one basic simple question. When I have multiple records in the datagrid as follows: Code Product 1 Product 2 Product 3 11111 A B C...
2
by: Iain | last post by:
Hi All I am witing a web app using Delphi developer 2006 (C# app) and I have a datagrid. Excuse the numptyness of the question. I have a datagrid with the ability to Insert, Edit/Update and...
17
by: mandanarchi | last post by:
Access 2003; PC with Windows XP; SBS 2003 I tried searching the forums but it came up with a blank page. I searched Google and found an answer; but the 'problem' doesn't relate to our situation!...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...

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.