Okay, I have the following scenerio:
Protected Sub DelRows()
Dim rw As DataRow
Dim rrw As DataRow
Dim DT as DataTable
Dim rws() as DataRow
For each rw in ds.Tables("Table1").Rows
rws = ds.Tables("Table2").Select("KeyRow = '" &
rw.Item(0).ToString & "'")
For Each rrw in rws
rrw.Delete()
Next
Next
End Sub
As you can see, I have 2 DataTables in my DataSet. I have to delete data
from Table2, and the key for that data is Item(0) in Table1. Now, I'm
thinking that this will delete the tables I selected out of Table2 from
Table2, but that's not what's working...
Help......
Sueffel
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.558 / Virus Database: 350 - Release Date: 1/2/2004 14 1270
Hi Sueffel, rws = ds.Tables("Table2").Select("KeyRow = '" &
Is "KeyRow" a real column name in table2?
If so test it once with a hard value in table2 on that KeyRow, that you
know, and debug it.
Cor
"Cor" <no*@non.com> wrote in message
news:uY**************@TK2MSFTNGP09.phx.gbl... Hi Sueffel,
rws = ds.Tables("Table2").Select("KeyRow = '" &
Is "KeyRow" a real column name in table2? If so test it once with a hard value in table2 on that KeyRow, that you know, and debug it.
Cor
KeyRow is just a name I threw out, the actual name of the column is
PaymentID, which is the PrimaryKey column. If I do this:
Dim T as String = rrw.Item(0).ToString, I get the value back. rrws return
sthe length correctly. I am now stumped on why it is not deleting. As a
"visual" thing, i bound a DataGrid to it and set the CaptionText to be the
count of rows for the table, and those don'tchange, but it does hit the
delete method. Hmmm again..
Sueffel
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.558 / Virus Database: 350 - Release Date: 1/2/2004
"Cor" <no*@non.com> wrote in message
news:uY**************@TK2MSFTNGP09.phx.gbl... Hi Sueffel,
rws = ds.Tables("Table2").Select("KeyRow = '" &
Is "KeyRow" a real column name in table2? If so test it once with a hard value in table2 on that KeyRow, that you know, and debug it.
Cor
As an added WTF, I stepped through the code and watched the rowstate, and it
did switch to Deleted, but I'm concerned that if isn't actually referencing
back to the base table as deleted.....
Sueffel
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.558 / Virus Database: 350 - Release Date: 1/2/2004
Hi Sueffel,
just a tempory mycounter as integer = ds.tables(x).rows.count
before it and after it, debug and you know.
(and the second one with another name) As an added WTF, I stepped through the code and watched the rowstate, and
it did switch to Deleted, but I'm concerned that if isn't actually
referencing back to the base table as deleted.....
Cor
"Cor" <no*@non.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... Hi Sueffel,
just a tempory mycounter as integer = ds.tables(x).rows.count before it and after it, debug and you know. (and the second one with another name) As an added WTF, I stepped through the code and watched the rowstate,
and it did switch to Deleted, but I'm concerned that if isn't actually referencing back to the base table as deleted..... Cor
Will give that a shot and let ya know.
Sueffel
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.558 / Virus Database: 350 - Release Date: 1/2/2004
"Cor" <no*@non.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... Hi Sueffel,
just a tempory mycounter as integer = ds.tables(x).rows.count before it and after it, debug and you know. (and the second one with another name) As an added WTF, I stepped through the code and watched the rowstate,
and it did switch to Deleted, but I'm concerned that if isn't actually referencing back to the base table as deleted..... Cor
Now somethings shedding light! I just did that, and what would ya know, the
RowCount did not change! Urrggghhhhhh
Sueffel
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.558 / Virus Database: 350 - Release Date: 1/2/2004
"Sueffel" <so*****@somewhere.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... "Cor" <no*@non.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... Hi Sueffel,
just a tempory mycounter as integer = ds.tables(x).rows.count before it and after it, debug and you know. (and the second one with another name) As an added WTF, I stepped through the code and watched the rowstate, and it did switch to Deleted, but I'm concerned that if isn't actually referencing back to the base table as deleted..... Cor
Now somethings shedding light! I just did that, and what would ya know,
the RowCount did not change! Urrggghhhhhh
Sueffel
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.558 / Virus Database: 350 - Release Date: 1/2/2004
Well shister! forgot ds.AcceptChanges()! LOL
All is well now LMAO
Sueffel
Sueffel, Well shister! forgot ds.AcceptChanges()! LOL
If you are not updating the backing database itself (DataAdapter.Update) you
can call DataRow.Remove instead of DataRow.Delete, DataRow.Remove will
remove the row from the DataTable immediately!
Note DataAdapter.Update should be calling AcceptChanges for you...
Hope this helps
Jay
"Sueffel" <so*****@somewhere.com> wrote in message
news:OW**************@TK2MSFTNGP11.phx.gbl... "Sueffel" <so*****@somewhere.com> wrote in message news:%2****************@tk2msftngp13.phx.gbl... "Cor" <no*@non.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... Hi Sueffel,
just a tempory mycounter as integer = ds.tables(x).rows.count before it and after it, debug and you know. (and the second one with another name) > > As an added WTF, I stepped through the code and watched the
rowstate, and it > did switch to Deleted, but I'm concerned that if isn't actually referencing > back to the base table as deleted..... > Cor
Now somethings shedding light! I just did that, and what would ya know,
the RowCount did not change! Urrggghhhhhh
Sueffel
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.558 / Virus Database: 350 - Release Date: 1/2/2004
Well shister! forgot ds.AcceptChanges()! LOL
All is well now LMAO Sueffel
Hi Sueffel,
Are you sure that did fix it?
I think it is something else this should not fix the problem in my opinion
(with the part of program I saw from you). Well shister! forgot ds.AcceptChanges()! LOL
Cor
"Cor" <no*@non.com> wrote in message
news:eW****************@TK2MSFTNGP12.phx.gbl... Hi Sueffel,
Are you sure that did fix it?
I think it is something else this should not fix the problem in my opinion (with the part of program I saw from you).
Well shister! forgot ds.AcceptChanges()! LOL
Cor
I haven't called the update yet. I know I can just display the deleted
rows to the user, but I'm opting to delete the rows, accept the changes to
the underlying dataset, then bind a datagrid to the dataset, and let the
user decide if they did it correctly, then commit it to the database. I
probably will take the rows marked deleted and dump them into another table
and have the user check that, withuot caling AcceptChanges, so then the user
can just cancel either some or all of the deleted rows and not have to
re-read the dataadapter from the database.
I want to give the user every chance to make sure they are deleting or
changing the right thing before making it perminant. Some of my users take
the notion of "Human Error" to a level that I haven't seen from 4th graders,
so I really need to be on my toes for stuff. So, that's why I have to use
"wierd methods" to get things done.
Thanks again,
Sueffel
Hi Sueffel,
Maybe I am wrong but I think you are interpretting accept.changes in the
wrong way.
(Look at the note from Jay B also for that).
You can use acceptchanges to fix the changes in the dataset (better fix the
rowstate) as update done.
The dataadapter does that also for you if you are writing something as
xxxdataadapter.update(mydataset)
But suppose you would not want to do that and you take another method to
update the dataset. (There can be reasons for that). Than you can use
dataset.acceptchanges to tell that you have done all the updates to the
database.
If you do not use updates to the database at all, you can also use as Jay B.
stated
dataset.xxxx.remove
I hope this makes it more clear
Cor
Sueffel,
As Cor pointed out, I too have concerns about you calling AcceptChanges,
then thinking you can update the DataBase. Calling DataSet.GetChanges to
show the to the user may be a better choice. GetChanges is the "easy" way to
"take the rows marked deleted and dump them into another table".
If you do not have it, I would strongly recommend you purchase and read,
thoroughly! David Sceppa's book "Microsoft ADO.NET - Core Reference" from MS
Press. It is both a good tutorial on ADO.NET as well as a good desk
reference once you know ADO.NET.
Sceppa's book provides lots of details on DataSets, DataTables, deleting,
presenting changes to user, along with updating the database.
Hope this helps
Jay
"Sueffel" <so*****@somewhere.com> wrote in message
news:uJ*************@TK2MSFTNGP11.phx.gbl... "Cor" <no*@non.com> wrote in message news:eW****************@TK2MSFTNGP12.phx.gbl... Hi Sueffel,
Are you sure that did fix it?
I think it is something else this should not fix the problem in my
opinion (with the part of program I saw from you).
Well shister! forgot ds.AcceptChanges()! LOL Cor
I haven't called the update yet. I know I can just display the
deleted rows to the user, but I'm opting to delete the rows, accept the changes to the underlying dataset, then bind a datagrid to the dataset, and let the user decide if they did it correctly, then commit it to the database. I probably will take the rows marked deleted and dump them into another
table and have the user check that, withuot caling AcceptChanges, so then the
user can just cancel either some or all of the deleted rows and not have to re-read the dataadapter from the database. I want to give the user every chance to make sure they are deleting or changing the right thing before making it perminant. Some of my users
take the notion of "Human Error" to a level that I haven't seen from 4th
graders, so I really need to be on my toes for stuff. So, that's why I have to use "wierd methods" to get things done.
Thanks again, Sueffel
I can see where my confusion is coming in. I'm looking at my book
again, and rereading the stuff on "Managing DataSet Changes". According to
this example they provide:
dsCustomers = dsCustomers.GetChanges(DataRowState.Deleted)
I concluded that I had to do this before using AcceptChanges. So, i
need to rethink the process to do the following:
1) Let users delete rows from DataSet.Table using DataRow.Delete
2) Provide a temprorary dataset, and return the GetChanges method there,
showing it through DataGrid
3) If user is liking it, then AcceptChanges, else RejectChanges
4) Tell the DataAdapter for this perticular Table in the DataSet to
Update(), committing these changes back tot he database.
5) Stop thinking in classic ADO methodology!!!!!!!!!
I see a concern in the code above, is this going to remove the rest of the
dataset and leave only rows that are deleted? I think that's what is
confusing me and tripping me up....
More food for my thought!
Thanks again,
Sueffel
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.564 / Virus Database: 356 - Release Date: 1/19/2004
Hi Sueffel
No
You are staying with the accept changes. Forget it a while.
Here row by row comments on your sentences. 1) Let users delete rows from DataSet.Table using DataRow.Delete
No problem
2) Provide a temprorary dataset, and return the GetChanges method there, showing it through DataGrid
No problem
3) If user is liking it, then AcceptChanges, else RejectChanges
A big problem, has to be "If the user is not liking it Reject Changes"
4) Tell the DataAdapter for this perticular Table in the DataSet to Update(), committing these changes back tot he database.
If you do not that acceptChanges, the dataAdapter does the accept changes
for you if you have used full dataset in the dataadapter(and only then).
If you have done acceptchanges before there is no need for an update,
because there is nothing to update anymore.
5) Stop thinking in classic ADO methodology!!!!!!!!!
Yes
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: jeff brubaker |
last post by:
Hello,
Currently we have a database, and it is our desire for it to be able
to store millions of records. The data in the table can be divided up
by client, and it stores nothing but about 7...
|
by: Doslil |
last post by:
I have a form which has a subform.In the main form I have only one
field (this is a drop down list and has a query attached to it) which
selects empno,Name from the EmployeeInformation table.
...
|
by: Shibu |
last post by:
Hi,
I have a situation where I need to convert business objects to a flat table.
The reverse is also required. I am using c# and
Oracle ODP. I am looking for an easier method to do the below...
|
by: joshsackett |
last post by:
I am having a problem with indexes on specific tables. For some reason
a query that runs against a view is not selecting the correct index on
a table. I run the same query against the table...
|
by: nyt |
last post by:
I have a problem of number and text field.
I got the database file(mdb) that contains many combo boxes used and
its list values are created by "value list"
For eg field
Field name= 'furniture'...
|
by: pemigh |
last post by:
A while back I imported tables to a new database via Files-->Get
External Data --> Import...
All was well for several months, and then the database started behaving
badly in a couple of ways,...
|
by: aharding |
last post by:
I have a form that displays data. I have a subform I created in the form, saved, deleted from form layout, and a command button that opens that subform. It works perfectly until I try to enter the...
|
by: Chris |
last post by:
All
I am cross-posting, as I'm not sure if this is an issue for the data layer
or the application layer. If this is unacceptable, can someone let me know
so that I don't do this in future.
...
|
by: quantumlady |
last post by:
Hi, All.
I am working on a project with another student that will be used on Oracle, MySWL and DB2 databases. We have completed all the basic functions, but I would like to see if we can improve...
|
by: AlexanderDeLarge |
last post by:
Hi!
I got a problem that's driving me crazy and I'm desperately in need of help.
I'll explain my scenario:
I'm doing a database driven site for a band, I got these tables for their discography...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
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...
|
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...
|
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,...
|
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...
|
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...
| |