473,382 Members | 1,705 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,382 software developers and data experts.

Delete a row in a dataset

I have a simple datatable in a dataset and cannot figure out how to delete
the current row in the dataset/table. I have been able to hard code the
current row value to a 1, and that works deleting just the first record.

ds.Tables["inquiry_data"].Rows[1].Delete();

How do i get the current row being displayed?
Aug 25 '08 #1
3 13727
On Aug 25, 6:44 pm, Toren Valone
<TorenVal...@discussions.microsoft.comwrote:
I have a simple datatable in a dataset and cannot figure out how to delete
the current row in the dataset/table. I have been able to hard code the
current row value to a 1, and that works deleting just the first record.

ds.Tables["inquiry_data"].Rows[1].Delete();

How do i get the current row being displayed?
Current row being displayed would be relative to the container object
(i.e. dataGridView) that's being used to display the DataTable
content, so you would need to fetch that value from the container. To
remove a row from a DataTable use the Remove or RemoveAt method off of
the Rows collection, off of the DataTable instance.

dt.Rows.Remove(myRow);
Aug 26 '08 #2
On Mon, 25 Aug 2008 16:44:06 -0700, Toren Valone wrote:
I have a simple datatable in a dataset and cannot figure out how to
delete the current row in the dataset/table. I have been able to hard
code the current row value to a 1, and that works deleting just the
first record.

ds.Tables["inquiry_data"].Rows[1].Delete();

How do i get the current row being displayed?
You are deleting the second record, not the first. [0] would be the first.

You delete using the binding source. I think the following is correct...

((DataRowView)bindingSource.Current).Delete();
Aug 26 '08 #3
Thanks, I ended up coding this and it works great.

int current = this.BindingContext[ds, "inquiry_data"].Position;

ds.Tables["vr_record"].Rows[current].Delete();

ds.AcceptChanges();
ds.WriteXml("vrdatabase.xml");

"Ken Foskey" wrote:
On Mon, 25 Aug 2008 16:44:06 -0700, Toren Valone wrote:
I have a simple datatable in a dataset and cannot figure out how to
delete the current row in the dataset/table. I have been able to hard
code the current row value to a 1, and that works deleting just the
first record.

ds.Tables["inquiry_data"].Rows[1].Delete();

How do i get the current row being displayed?

You are deleting the second record, not the first. [0] would be the first.

You delete using the binding source. I think the following is correct...

((DataRowView)bindingSource.Current).Delete();
Aug 26 '08 #4

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

Similar topics

4
by: baylor | last post by:
i have a DataSet (TDS). It has 4 rows in it. i want to erase those. For the life of me i can't figure out how Option 1: foreach foreach (DataRow row in dataSet.MY_TABLE.Rows) { row.Delete(); }...
5
by: Grant | last post by:
Hello, How come when I add a new row to my dataset table it shows up as changed (agencyData.Haschanges() = True) but when I delete a row the dataset thinks here are no...
4
by: Steven Nagy | last post by:
Hi Have a problem that consistantly occurs in my applications where using a DataAdapter (OLEDB) and a dataset. Using a simple process of adding a row to the dataset table and then calling the...
2
by: NoSpam | last post by:
Hi, I am working with C# and ASP.NET with code behind and a SQL Server. I'm making an e-shop. When clients see what they have in their basket, I added a function DELETE to delete a line. It took...
6
by: Mark Kurten | last post by:
for some reason when i delete a row, the row doesn't get deleted from the acutal data table in SQL server. my code follows what am i missing? thanks. Dim row As DataRow Try
5
by: tony010409020622 | last post by:
I just spent 4 months taking a dotnet class where i learned very little. One of the things I did not learn is this: What are the dotnet equivilents of commands such as: Adodc1.Recordset.AddNew...
7
by: travlintom | last post by:
Hi. I'm new to VB.net and am used to working with recordsets (much easier). I have a datagrid that, when the user double clicks on a row, I am giving them a chance to delete it. I thought this...
5
by: rn5a | last post by:
The .NET 2.0 documentation states the following: When using a DataSet or DataTable in conjunction with a DataAdapter & a relational data source, use the Delete method of the DataRow to remove...
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...
5
by: Tony Johansson | last post by:
Hello! Here I have a working program that delete the specified row in the database. It works fine but I want to fully understand it. In this example the SQLCommandBuilder will automatically...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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...

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.