datarow updates not showing in datatable

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello.
I have a dataset with multiple datatables. For the large tables, I just
have the one target row in the datatable, and a datarow variable assigned to
that row, like:

m_loadRecordRW(dtGenerator.TableName, sSQL)
m_drGenerator = dtGenerator.Rows(0)

Private Sub m_loadRecordRW(ByVal sTableName As String, ByVal sFilter As
String)
Dim dt As DataTable
dt = m_objSQLCEDB.tbl_RW(sTableName, sFilter) ' creates the da
m_ds.Tables.Add(dt)
End Sub

When I make changes to fields in the datarow, they don't appear in the
datatable in the dataset, so the update only works if I update both the
datarow and the dataset:

Friend Sub updateGenItem(ByVal sVal As String)
m_ds.Tables(m_csTblGeneratorRW).Rows(0)(m_objGeneratorItem.fieldName) = sVal
m_drGenerator(m_objGeneratorItem.fieldName) = sVal
m_update(m_ds.Tables(m_csTblGeneratorRW))
End Sub

I don't understand why the update to the datarow doesn't appear in the
dataset.

Let me know if I need to post additional code to make the situation clear.

All I want to do is create a datarow variable pointing to a datatable in a
dataset, update a field in the datarow, update the dataadapter filled from
the datatable, and have the dataadapter recognize the update.

Thanks for any help,

-Beth
 
I'm confused. Is that what you're trying to do?

Imports System
Imports System.Windows.Forms
Imports System.Data
Imports System.Drawing
Imports System.IO

Public Class SimpleTest

Public Shared Sub Main(ByVal args() As String)
Dim dr as DataRow

Dim dt as new DataTable()
dt.Columns.Add ("Column")
dr = dt.NewRow()

dr(0) = "hello"

dt.Rows.Add(dr)

Console.WriteLine ("Value in row: '{0}'; Value in table '{1}'", dr(0),
dt.Rows(0)(0))

dr(0) = "buy"

Console.WriteLine ("Value in row: '{0}'; Value in table '{1}'", dr(0),
dt.Rows(0)(0))

End Sub

End Class

As you could see, it works just fine. Make sure you're not missing the
table (i.e. dtGenerator is the same as m_ds.Tables(m_csTblGeneratorRW))
and/or row.

I f not, please post complete and compliable code to illustrate the problem
(do not use 3rd part assemblies and your wrapper classes if possible, see
sample above).

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
 
Ilya,
Thanks for your help. I figured out what I was doing wrong.

I have one datatable that is read-only created from querying a table in the
..sdf with search criteria, and a data row pointing to the first row of that
datatable.

If the row was found, I create a second datatable by filling a data adapter,
and that's the table I add to the dataset. I have a second datarow pointing
to the first row of the datatable with the dataadapter. That's the row I
edit when they change values at runtime.

So I really needed to distinguish between the two tables and rows- the
read-only ones created with the search results and the read-write ones added
to the dataset created by filling a data adapter.

Thanks again for the help- I needed to know if it was something I was doing
wrong or if it was something unsupported.

-Beth
"Ilya Tumanov [MS]" said:
I'm confused. Is that what you're trying to do?

Imports System
Imports System.Windows.Forms
Imports System.Data
Imports System.Drawing
Imports System.IO

Public Class SimpleTest

Public Shared Sub Main(ByVal args() As String)
Dim dr as DataRow

Dim dt as new DataTable()
dt.Columns.Add ("Column")
dr = dt.NewRow()

dr(0) = "hello"

dt.Rows.Add(dr)

Console.WriteLine ("Value in row: '{0}'; Value in table '{1}'", dr(0),
dt.Rows(0)(0))

dr(0) = "buy"

Console.WriteLine ("Value in row: '{0}'; Value in table '{1}'", dr(0),
dt.Rows(0)(0))

End Sub

End Class

As you could see, it works just fine. Make sure you're not missing the
table (i.e. dtGenerator is the same as m_ds.Tables(m_csTblGeneratorRW))
and/or row.

I f not, please post complete and compliable code to illustrate the problem
(do not use 3rd part assemblies and your wrapper classes if possible, see
sample above).

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
Thread-Topic: datarow updates not showing in datatable
thread-index: AcUestLB+gxoRpSjReO1+PVJUKdrMw==
X-WBNR-Posting-Host: 204.73.55.90
From: "=?Utf-8?B?QmV0aA==?=" <[email protected]>
Subject: datarow updates not showing in datatable
Date: Tue, 1 Mar 2005 15:03:03 -0800
Lines: 38
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.compactframework
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTCMTY1.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.framework.compactframework:72198
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Hello.
I have a dataset with multiple datatables. For the large tables, I just
have the one target row in the datatable, and a datarow variable assigned to
that row, like:

m_loadRecordRW(dtGenerator.TableName, sSQL)
m_drGenerator = dtGenerator.Rows(0)

Private Sub m_loadRecordRW(ByVal sTableName As String, ByVal sFilter As
String)
Dim dt As DataTable
dt = m_objSQLCEDB.tbl_RW(sTableName, sFilter) ' creates the da
m_ds.Tables.Add(dt)
End Sub

When I make changes to fields in the datarow, they don't appear in the
datatable in the dataset, so the update only works if I update both the
datarow and the dataset:

Friend Sub updateGenItem(ByVal sVal As String)
m_ds.Tables(m_csTblGeneratorRW).Rows(0)(m_objGeneratorItem.fieldName) = sVal
m_drGenerator(m_objGeneratorItem.fieldName) = sVal
m_update(m_ds.Tables(m_csTblGeneratorRW))
End Sub

I don't understand why the update to the datarow doesn't appear in the
dataset.

Let me know if I need to post additional code to make the situation clear.

All I want to do is create a datarow variable pointing to a datatable in a
dataset, update a field in the datarow, update the dataadapter filled from
the datatable, and have the dataadapter recognize the update.

Thanks for any help,

-Beth
 
Back
Top