473,387 Members | 3,781 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.

delete db row via tableadapter?

AW
XP & VB 2005 using the help files - followed instructions to use the
table adapter to delete a row from the database.
I step thru the table find the rows to delete and
issue a .Delete() and
after having done that for all the rows I want to delete
issue an AcceptChanges().
I get NO errors but the database is unchanged.
Google has several suggestions that seem very complex.
VB 2005 is supposed to be simple and direct - Not?
Help? Suggestions? Point to help? Thanks.
Feb 10 '08 #1
4 7933
AW,

A database has nothing to do with an AcceptChanges, what an accept changes
does is setting all the rows to unchanged and removing all rows that have
the rowstate deleted. All first state information is removed from the Row.

Deleting a row in a database goes in fact with a SQL statement.

If you use a datatable however, then the delete is done by the DataAdapter
in the Update of the TableAdapter (which I never have used) or the
DBDataAdapter (which I always use).

Therefore, show some code.

Cor

Feb 10 '08 #2
On Sat, 09 Feb 2008 22:03:58 -0800, AW <wrote:
>XP & VB 2005 using the help files - followed instructions to use the
table adapter to delete a row from the database.
I step thru the table find the rows to delete and
issue a .Delete() and
after having done that for all the rows I want to delete
issue an AcceptChanges().
I get NO errors but the database is unchanged.
Google has several suggestions that seem very complex.
VB 2005 is supposed to be simple and direct - Not?
Help? Suggestions? Point to help? Thanks.
You need to call dataadapter.Update() before calling
datatable.AcceptChanges().

dataadapter.Update() is what updates the database with the rows that
are modified in the datatable. Datatable.AcceptChanges() then marks
all of the rows in the datatable as being not modified.

Don't forget to build the dataadapter DeleteCommand, InsertCommand and
UpdateCommand properties with the appropriate SQL statements.
Feb 10 '08 #3
AW
On Sun, 10 Feb 2008 07:34:15 +0100, "Cor Ligthert[MVP]"
<no************@planet.nlwrote:
>AW,

A database has nothing to do with an AcceptChanges, what an accept changes
does is setting all the rows to unchanged and removing all rows that have
the rowstate deleted. All first state information is removed from the Row.

Deleting a row in a database goes in fact with a SQL statement.

If you use a datatable however, then the delete is done by the DataAdapter
in the Update of the TableAdapter (which I never have used) or the
DBDataAdapter (which I always use).

Therefore, show some code.

Cor
OK, I followed some of your advice - I created a DeleteQuery in the
TableAdapter. Then I looped thru the rows of the DataGridView and when
I found a row to delete, I called the Sql DeleteQuery with Where
(ColSym=string) - TableAdapter.DeleteQuery(str)
And then ran the program again - deleted stuff gone.
Amazingly simple but try finding it in "help".
Feb 11 '08 #4
OK, I followed some of your advice - I created a DeleteQuery in the
TableAdapter. Then I looped thru the rows of the DataGridView and when
I found a row to delete, I called the Sql DeleteQuery with Where
(ColSym=string) - TableAdapter.DeleteQuery(str)
And then ran the program again - deleted stuff gone.
Amazingly simple but try finding it in "help".
You should never try to access the grid directly, one of the reasons is,
that because that it can be sorted, the showed rows can be not in line with
the real rows.

Try to use forever what is in the BindingSoure. (The datasource).

I never use the tableadapters, however a text from Ken.

http://www.vb-tips.com/ExtendTableAdapter.aspx

Cor

Feb 12 '08 #5

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

Similar topics

5
by: Programatix | last post by:
Hi, Have anyone ever benchmark the TableAdapter performance compared to DataTable's Load method? I found out that the DataTable's Load method is about 10x faster than TableAdapter's Fill method....
9
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
15
by: philip | last post by:
On a form, I have a datagridview. This datagridview is constructed on a dataset filled by a tableadapter. The table adapter do very well what it must do when filling dataset. Insertions,...
2
by: Rodrigo Ferreira | last post by:
Hi How can i delete a row from a datagrid with code? I want the same efectt that when i click in delete key. Greetings
1
by: Demetri | last post by:
I have a question / concern regarding the new suggested way of creating a data access layer in an n-tier application. Typically, a web application specifically, using the SOA (Service Oriented...
0
by: TinMan | last post by:
in my 2.0 ASP.Net app I'm using the TableAdapter Configuration wizard and asking it to generate Selece, Update, Insert, and Delete. It did not generate the delete! Why? Thanks, T
2
by: GaryDean | last post by:
I'm comparing use of DataView -ObjectDataSource -TableAdapter to DataView -SqlDataSource using the Customers table on the NorthWind database. The SQL given to both wizards is: SELECT ...
3
by: =?Utf-8?B?UmljaCBIdXRjaGlucw==?= | last post by:
I'm not really sure how to ask this question because I'm still getting my feet wet with data access and VB.NET, but here goes: To start off with, I'm using VB 2005 Express to connect to an Access...
0
by: =?Utf-8?B?Q3JhaWcgQnVjaGFuYW4=?= | last post by:
Assuming that I have a table with a single, auto-generated primary key and a TableAdapter/DataTable that references it, what would happen if I add a new row to the DataTable in code, Delete it,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.