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

getchanges returns nothing

Sam
Hi,

Here is my code :

For Each row As DataRow In m_dsTabs.Tables(0).Rows
If CInt(row("TabId")) = DirectCast(tabQryTabs.SelectedTab,
QueryTabPage).TabId Then
m_dsTabs.Tables(0).Rows.Remove(row)
Exit For
End If
Next
m_dsTabs.AcceptChanges()
m_dsTabs.GetChanges(DataRowState.Deleted)

GetChanges returns nothing. Why ? And do you think my method for
removing a row given a particular TabId (primary key of my table) is a
good way to do so?

Thx

Nov 21 '05 #1
8 2923
"Sam" <sa**************@voila.fr> schrieb
Hi,

Here is my code :

For Each row As DataRow In m_dsTabs.Tables(0).Rows
If CInt(row("TabId")) = DirectCast(tabQryTabs.SelectedTab,
QueryTabPage).TabId Then
m_dsTabs.Tables(0).Rows.Remove(row)
Exit For
End If
Next
m_dsTabs.AcceptChanges()
m_dsTabs.GetChanges(DataRowState.Deleted)

GetChanges returns nothing. Why ?
Because you called AcceptChanges, and this removes the deleted rows from the
table. Afterwards, there are no rows with rowstate=deleted in the table and
getchanges returns nothing.
And do you think my method for
removing a row given a particular TabId (primary key of my table) is
a good way to do so?

dim id as integer
dim row as datarow

id = DirectCast(tabQryTabs.SelectedTab, QueryTabPage).TabId
row = m_dsTabs.Tables(0).Rows.Find(ID)
if not row is nothing then row.Delete

is probably faster (or shorter (or easier)).

Armin

Nov 21 '05 #2
Sam
Thx :)

Nov 21 '05 #3
Sam
Actually I've got the error :
System.Data.MissingPrimaryKeyException - Table doesn't have a primary
key.
on that line

row = m_dsTabs.Tables(0).Rows.Find(TabId)

TabId is the primary key in my database's table but I don't know how to
set it to be my primary key in my dataset ??

Nov 21 '05 #4
Sam
Ok, I've found out :)

Dim pk(0) As DataColumn
pk(0) = m_dsTabs.Tables(0).Columns("TabId")
m_dsTabs.Tables(0).PrimaryKey = pk

Now it works .

Thx again

Nov 21 '05 #5
Sam
Ok, I've found out :)

Dim pk(0) As DataColumn
pk(0) = m_dsTabs.Tables(0).Columns("TabId")
m_dsTabs.Tables(0).PrimaryKey = pk

Now it works .

Thx again

Nov 21 '05 #6
Sam
Actually I have another problem related to this:

dt = m_dsTabs.Tables(0).GetChanges(DataRowState.Deleted )

If I try to access dt.Rows(0).Item("TabID") then I get :

System.Data.DeletedRowInaccessibleException - Deleted row information
cannot be accessed through the row.

I would have thought that dt would contain the data of the deleted row
?
If not, how can I get this information ?

Thx

Nov 21 '05 #7
Sam,

Maybe by a

dt.rejectchanges

I hope this helps,

Cor
Nov 21 '05 #8
Sam
Thx a lot !

Nov 21 '05 #9

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

Similar topics

2
by: JochenZ | last post by:
Hello, I have a DataGrid(View) and a DataTable. The DataTable is displayed in the DataGridView: dataGridView.DataSource = theTable; The user is allowed to select some rows and then the...
1
by: Marty | last post by:
In winforms, I can bind a datagrid to a dataset. When the user wants to submit changes, it's easy to see what has changed with the DataSet "GetChanges" method. In ASP.Net, I can create the...
24
by: Sam | last post by:
Hi, I have a datagrid which source is a dataset : dgFields.Rows.DataMember = m_dsFields.Tables(0).TableName dgFields.Rows.DataSource = m_dsFields Now my values are displayed properly and when...
1
by: kcakebread | last post by:
Using VB 2005, I have a strongly typed dataset (from a .xsd file in my project). When I load data into this dataset, the immediate window shows: ?ds.TableX(0).IstheFieldNull True So,...
4
by: George | last post by:
Got a question about the side effect of DataAdapter.Update() and DataTable.GetChanges(). Say I set up a DataTable and a DataAdapter in a class. Delete (Not remove) a row in the data table and...
1
by: matt | last post by:
hello, i have a web app that allows users to query our oracle db and produce a dataset of report data. they then have the option to serialize this data and store it in the database. later, then...
1
by: daranee | last post by:
Documentation on GetChanges say the following: Gets a copy of the DataSet that contains all changes made to it since it was loaded or AcceptChanges was last called. Does this mean I can update via...
0
by: Jim | last post by:
Hi, ..Net 2003, Language: VB Problem: Populating a Dataset with a datatable, the columns of which are bound to controls on a form. I'm assigning the value directly in 2 of the fields of the...
3
by: John Sheppard | last post by:
Hello there, I have the following code; I do this as a work around for a dataset.haschanges method which doesnt appear to work correctly either For Each dt As DataTable In myDs.Tables If Not...
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
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...

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.