473,387 Members | 1,455 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,387 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 1244

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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.