Hello,
I have a datagrid (grdShots) on a form, and a button to allow the user
to delete records from the dataset underlying the grid. My code
appears to work, because the row disappears from the datagrid. But the
delete is not being updated back to the data source, because if I exit
the app then start it again, the record reappears in the grid - it has
not been deleted. Code for deleting the row is as follows. Column 0
in the grid is the ID of the record, which is its primary key.
Dim iImage as Long
Dim dr as DataRow
iImage = grdShots.Item(g rdShots.Current RowIndex, 0)
If MsgBox("Are you sure you want to delete this?",
MsgBoxStyle.Que stion + MsgBoxStyle.Yes No) = MsgBoxResult.Ye s Then
dr = dsShots.Tables( "Shot").Rows.Fi nd(iImage)
dsShots.Tables( "Shot").Rows.Re move(dr)
daShots.Update( dsShots)
End If
What more do I need to do? 3 1747
Marshall,
Replace the remove by a "delete" equivalent.
The remove, removes a datarow from a datatable/dataset
The delete marks a row as to be removed by the next update or by an
acceptchanges.
I hope this helps,
Cor
"marshallar ts" <st****@westnet .net.au> schreef in bericht
news:11******** **************@ j33g2000cwa.goo glegroups.com.. . Hello,
I have a datagrid (grdShots) on a form, and a button to allow the user to delete records from the dataset underlying the grid. My code appears to work, because the row disappears from the datagrid. But the delete is not being updated back to the data source, because if I exit the app then start it again, the record reappears in the grid - it has not been deleted. Code for deleting the row is as follows. Column 0 in the grid is the ID of the record, which is its primary key.
Dim iImage as Long Dim dr as DataRow
iImage = grdShots.Item(g rdShots.Current RowIndex, 0) If MsgBox("Are you sure you want to delete this?", MsgBoxStyle.Que stion + MsgBoxStyle.Yes No) = MsgBoxResult.Ye s Then dr = dsShots.Tables( "Shot").Rows.Fi nd(iImage) dsShots.Tables( "Shot").Rows.Re move(dr) daShots.Update( dsShots) End If
What more do I need to do?
Unbelievable! Thank you, that worked. When would anyone use the
Remove method, for heaven's sake?? I can't get my head around what its
purpose is.
"Steve Marshall" <st****@westnet .net.au> wrote in message
news:11******** **************@ v46g2000cwv.goo glegroups.com.. . Unbelievable! Thank you, that worked. When would anyone use the Remove method, for heaven's sake?? I can't get my head around what its purpose is.
Possibly after a Remove that row will not be altered on the DB after a
resynch? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Junkguy |
last post by:
I'm having difficulty deleting rows from a datagrid. I want to put a "delete"
button on a form and achieve the same functionality as hitting the "delete"
key on the keyboard for the selected row of a datagrid.
I really want to do it generically so I have subclassed datagrid and made my
own delete row method but I can only get it to work for datasources that are
datatables or dataviews.
Specifically when the datasource is a DataSet I...
|
by: Christoph |
last post by:
I'm delving into using ADO.NET for the first time. In fact, I've never
done any database work using C# at all so all of this is new to me.
Please bear that in mind if I am asking stupid questions.
In reading the documentation for the "Update()" method of the
SqlDataAdapter class, I see that it "Calls the respective INSERT, UPDATE,
or DELETE statements for each inserted, updated or deleted rows in the
specified array of DataRow objects"....
|
by: Mojtaba Faridzad |
last post by:
Hi,
with SetDataBinding( ) a DataGrid shows a DataView. user can select some
rows in the grid by holding cotrol key. when user clicks on Delete button, I
should delete all selected rows. I am trying to delete these lines from the
dataview like this:
for (int i=0; i < dataView.Count; i++)
if (dataGrid.IsSelected(i))
dataView.Delete(i);
|
by: Abra |
last post by:
My C# application has a list (ListBox object), connected over a DataView
to a dataset which corresponds to a table from a MySql database. I want
to delete for example 4000-5000 rows from the table, which correspond to
a certain filter.
If I iterate the Rows from the table and check for each one the filter
condition and, if true, I call the Delete() method, it takes several
minutes till the respective rows are deleted. I tried also to...
|
by: Robert Brown |
last post by:
Hi All.
I have a routine that checks a SQL Table for all records 3 months
prior to a predetermined date, then I insert them into an Archive DB
then delete those records from the original table.
When I do a "select" for the records, I load them into a dataset, use
an "insert" statement to insert the info into the second table (by a
for next loop and using executenonquery , then a "delete" statement to
remove them.
| |
by: Bob Day |
last post by:
I need to delete ALL rows in a dataset and currently use the method in the
code snippet below, which works fine. However, there can be 100,000 rows,
which makes the FILL, DR.Delete and UPDATE take a very long time.
Is there a way to simply delete the entire dataset and then update that to
the datasource more effectinely?
Thanks!
Bob Day
|
by: Jim Michaels |
last post by:
Is it safe to do what is below? deleting from a resultset while you are
processing it? I don't know how dynamic the SQL database is. I assume you
get a cursor to live dataset. Even if it is a cursor as opposed to a table,
will the cursor's integrity be ruined if the current record is deleted?
$q2=mysql_query("SELECT * FROM table1 WHERE id1=5", $link);
while ($row2=mysql_fetch_array($q2)) {
//do some stuff with resultset...
|
by: Bob |
last post by:
Hi,
I have a typed unbound dataset that is passed to a datahandling class to be
filled.
The datahandling class fills it from a sproc using an oledbDataAdapter
(SQLAnywhere database)
The only table in the dataset has two int32 columns.
There is one row of data and as expected, column 0 contains an int and
column 1 contains a null.
I want to update column1.
The following code executes but the row cell remains unchanged.
|
by: sherifffruitfly |
last post by:
Hi,
I want to delete rows from my database. So I download them to a
dataset, and then discover the following.
This does not work:
dataset.Rows.Clear();
dataadapter.Update(dataset, "tablename");
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |