Hello Everyone
I've got a problem when I set a value into a DataRow X after an
Acceptchanges() on DataTable that contains X. After this operation
DataRow.Rowstate is Unchanged... strange... it must be Modified ..
isn't it?


I you see the following code (just "little boring"...)

Public Class testclass
Protected mDataTable As Data.DataTable
Protected mRow As Data.DataRow
Protected mDataAdapter As SqlClient.SqlDataAdapter
Protected mConn As SqlClient.SqlConnection
'----------------------------
' New
'----------------------------
Public Sub New()
mDataTable = New Data.DataTable()
mConn = New SqlClient.SqlConnection("Data
Source=test-srv;Integrated Security=SSPI;Initial Catalog=Test")
mDataAdapter = New SqlClient.SqlDataAdapter("SELECT ID,
Descrizione FROM Table", mConn)

mDataAdapter.FillSchema(mDataTable, SchemaType.Mapped)
mRow = mDataTable.NewRow()
End Sub


Public Sub Insert()
If mRow.RowState <> DataRowState.Detached Then Exit Sub
mRow(0) = "c51ac21a-05bc-475c-ad75-1affd8f980c3"
mRow(1) = "Hello!!"

'--------------------------------------------
' Delete evenually records from DataTable
'--------------------------------------------
mDataTable.Clear()
'-----------------------------------------
' AddRow
'-----------------------------------------
mDataTable.Rows.Add(mRow)
Debug.WriteLine(mRow.RowState)

'---------------------------
'Accept
'----------------------------
mDataTable.AcceptChanges()
Debug.WriteLine(mRow(1, DataRowVersion.Original) & " " &
mRow(1, DataRowVersion.Current) & " " & mRow.RowState)
'----------------------------------------
' Try to change value BUT!!!!!
'----------------------------------------
mRow(1) = "Foo2"
Debug.WriteLine(mRow(1, DataRowVersion.Original) & " " &
mRow(1, DataRowVersion.Current) & " " & mRow.RowState)

mRow(1) = "Foo3"
Debug.WriteLine(mRow(1, DataRowVersion.Original) & " " &
mRow(1, DataRowVersion.Current) & " " & mRow.RowState)

End Sub

AND CLIENT USER...

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim trow As New testclass()
trow.Insert()

End Sub

End Class


You can see that after AcceptChanges is all ok... (Rowstate=
Unchanged) but when I set:
mRow(1) = "Foo2"

mRow.rowstate remains Unchanged....

Please Help me!!

Marco Gatto

Re: Problem With DataRow Rowstate by Derek

Derek
Wed Jul 30 13:26:38 CDT 2003

Hi Marco.

>>after an
>>Acceptchanges() on DataTable that contains X. After this operation
>>DataRow.Rowstate is Unchanged... strange... it must be Modified ..

After changes are accepted the rowstate is now Unchanged. :)
[dataAdapter.Fill() and .Update() resets the rowstates to unchanged...

Derek LaZard


"Marco Gatto" <marcogatto@inwind.it> wrote in message
news:c7545cd7.0307290321.1f2b09b1@posting.google.com...
> Hello Everyone
> I've got a problem when I set a value into a DataRow X after an
> Acceptchanges() on DataTable that contains X. After this operation
> DataRow.Rowstate is Unchanged... strange... it must be Modified ..
> isn't it?
>
>
> I you see the following code (just "little boring"...)
>
> Public Class testclass
> Protected mDataTable As Data.DataTable
> Protected mRow As Data.DataRow
> Protected mDataAdapter As SqlClient.SqlDataAdapter
> Protected mConn As SqlClient.SqlConnection
> '----------------------------
> ' New
> '----------------------------
> Public Sub New()
> mDataTable = New Data.DataTable()
> mConn = New SqlClient.SqlConnection("Data
> Source=test-srv;Integrated Security=SSPI;Initial Catalog=Test")
> mDataAdapter = New SqlClient.SqlDataAdapter("SELECT ID,
> Descrizione FROM Table", mConn)
>
> mDataAdapter.FillSchema(mDataTable, SchemaType.Mapped)
> mRow = mDataTable.NewRow()
> End Sub
>
>
> Public Sub Insert()
> If mRow.RowState <> DataRowState.Detached Then Exit Sub
> mRow(0) = "c51ac21a-05bc-475c-ad75-1affd8f980c3"
> mRow(1) = "Hello!!"
>
> '--------------------------------------------
> ' Delete evenually records from DataTable
> '--------------------------------------------
> mDataTable.Clear()
> '-----------------------------------------
> ' AddRow
> '-----------------------------------------
> mDataTable.Rows.Add(mRow)
> Debug.WriteLine(mRow.RowState)
>
> '---------------------------
> 'Accept
> '----------------------------
> mDataTable.AcceptChanges()
> Debug.WriteLine(mRow(1, DataRowVersion.Original) & " " &
> mRow(1, DataRowVersion.Current) & " " & mRow.RowState)
> '----------------------------------------
> ' Try to change value BUT!!!!!
> '----------------------------------------
> mRow(1) = "Foo2"
> Debug.WriteLine(mRow(1, DataRowVersion.Original) & " " &
> mRow(1, DataRowVersion.Current) & " " & mRow.RowState)
>
> mRow(1) = "Foo3"
> Debug.WriteLine(mRow(1, DataRowVersion.Original) & " " &
> mRow(1, DataRowVersion.Current) & " " & mRow.RowState)
>
> End Sub
>
> AND CLIENT USER...
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
> As System.EventArgs) Handles Button1.Click
> Dim trow As New testclass()
> trow.Insert()
>
> End Sub
>
> End Class
>
>
> You can see that after AcceptChanges is all ok... (Rowstate=
> Unchanged) but when I set:
> mRow(1) = "Foo2"
>
> mRow.rowstate remains Unchanged....
>
> Please Help me!!
>
> Marco Gatto



Re: Problem With DataRow Rowstate by Derek

Derek
Thu Jul 31 11:55:26 CDT 2003

This is a multi-part message in MIME format.

------=_NextPart_000_0041_01C3575A.A1D01E30
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Marco, I'm getting a rowState =3D modified in C#, after the first edit =
update to the row in the DataTable...hmm...:

...
TableOfDeletes =3D dsAuthors.Tables["authors"].Clone();
ry =3D TableOfDeletes.NewRow();
TableOfDeletes.Rows.Add( ry);
ry[0] =3D "111-11-1111";
TableOfDeletes.AcceptChanges(); //ry is now unchanged
ry[0] =3D "333-33-3333"; //ry is now modified
...

I'll try it in VB...
BTW, Did you check this in the debugger?

Derek LaZard




"Marco Gatto" <marcogatto@inwind.it> wrote in message =
news:c7545cd7.0307302247.1847258d@posting.google.com...
> Sorry Derek but I didn't explain very well.... :)
>=20
> Step1 Insert New Row X ----> Detached (OK)
> Step2 Add X ----> Added (OK)
> Step3 AcceptChanges ----> Unchanged(OK)
> Step4 Set New Value (Foo2) ----> Unchanged(NOOO)
> Step5 Set New Value (Foo3) ----> Modified (...)
>=20
> Marco Gatto
>=20
> "Derek LaZard" <derekll@mindspring.com> wrote in message =
news:<ehE97AtVDHA.532@TK2MSFTNGP10.phx.gbl>...
> > Hi Marco.
> >=20
> > >>after an
> > >>Acceptchanges() on DataTable that contains X. After this operation
> > >>DataRow.Rowstate is Unchanged... strange... it must be Modified ..
> >=20
> > After changes are accepted the rowstate is now Unchanged. :)
> > [dataAdapter.Fill() and .Update() resets the rowstates to =
unchanged...
> >=20
> > Derek LaZard
> >=20
> >=20
> > "Marco Gatto" <marcogatto@inwind.it> wrote in message
> > news:c7545cd7.0307290321.1f2b09b1@posting.google.com...
> > > Hello Everyone
> > > I've got a problem when I set a value into a DataRow X after an
> > > Acceptchanges() on DataTable that contains X. After this operation
> > > DataRow.Rowstate is Unchanged... strange... it must be Modified ..
> > > isn't it?
> > >
> > >
> > > I you see the following code (just "little boring"...)
> > >
> > > Public Class testclass
> > > Protected mDataTable As Data.DataTable
> > > Protected mRow As Data.DataRow
> > > Protected mDataAdapter As SqlClient.SqlDataAdapter
> > > Protected mConn As SqlClient.SqlConnection
> > > '----------------------------
> > > ' New
> > > '----------------------------
> > > Public Sub New()
> > > mDataTable =3D New Data.DataTable()
> > > mConn =3D New SqlClient.SqlConnection("Data
> > > Source=3Dtest-srv;Integrated Security=3DSSPI;Initial =
Catalog=3DTest")
> > > mDataAdapter =3D New SqlClient.SqlDataAdapter("SELECT ID,
> > > Descrizione FROM Table", mConn)
> > >
> > > mDataAdapter.FillSchema(mDataTable, SchemaType.Mapped)
> > > mRow =3D mDataTable.NewRow()
> > > End Sub
> > >
> > >
> > > Public Sub Insert()
> > > If mRow.RowState <> DataRowState.Detached Then Exit Sub
> > > mRow(0) =3D "c51ac21a-05bc-475c-ad75-1affd8f980c3"
> > > mRow(1) =3D "Hello!!"
> > >
> > > '--------------------------------------------
> > > ' Delete evenually records from DataTable
> > > '--------------------------------------------
> > > mDataTable.Clear()
> > > '-----------------------------------------
> > > ' AddRow
> > > '-----------------------------------------
> > > mDataTable.Rows.Add(mRow)
> > > Debug.WriteLine(mRow.RowState)
> > >
> > > '---------------------------
> > > 'Accept
> > > '----------------------------
> > > mDataTable.AcceptChanges()
> > > Debug.WriteLine(mRow(1, DataRowVersion.Original) & " " &
> > > mRow(1, DataRowVersion.Current) & " " & mRow.RowState)
> > > '----------------------------------------
> > > ' Try to change value BUT!!!!!
> > > '----------------------------------------
> > > mRow(1) =3D "Foo2"
> > > Debug.WriteLine(mRow(1, DataRowVersion.Original) & " " &
> > > mRow(1, DataRowVersion.Current) & " " & mRow.RowState)
> > >
> > > mRow(1) =3D "Foo3"
> > > Debug.WriteLine(mRow(1, DataRowVersion.Original) & " " &
> > > mRow(1, DataRowVersion.Current) & " " & mRow.RowState)
> > >
> > > End Sub
> > >
> > > AND CLIENT USER...
> > >
> > > Private Sub Button1_Click(ByVal sender As System.Object, ByVal =
e
> > > As System.EventArgs) Handles Button1.Click
> > > Dim trow As New testclass()
> > > trow.Insert()
> > >
> > > End Sub
> > >
> > > End Class
> > >
> > >
> > > You can see that after AcceptChanges is all ok... (Rowstate=3D
> > > Unchanged) but when I set:
> > > mRow(1) =3D "Foo2"
> > >
> > > mRow.rowstate remains Unchanged....
> > >
> > > Please Help me!!
> > >
> > > Marco Gatto
------=_NextPart_000_0041_01C3575A.A1D01E30
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1106" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Marco, I'm getting a rowState =3D modified in C#, =
after the=20
first edit update to the row in the DataTable...hmm...:</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>...</FONT></DIV>
<DIV><FONT size=3D2>TableOfDeletes =3D=20
dsAuthors.Tables["authors"].Clone();</FONT></DIV>
<DIV><FONT size=3D2>ry =3D TableOfDeletes.NewRow();</FONT></DIV>
<DIV><FONT size=3D2>TableOfDeletes.Rows.Add( ry);</FONT></DIV>
<DIV><FONT size=3D2>ry[0] =3D "111-11-1111";</FONT></DIV>
<DIV><FONT size=3D2>TableOfDeletes.AcceptChanges();&nbsp;&nbsp;&nbsp; =
//ry is now=20
unchanged</FONT></DIV>
<DIV><FONT size=3D2>ry[0] =3D "333-33-3333";&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //ry is now=20
modified</FONT></DIV>
<DIV><FONT size=3D2>...</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I'll try it in VB...</FONT></DIV>
<DIV><FONT size=3D2>BTW, Did you check this in the =
debugger?</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Derek LaZard</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>"Marco Gatto" &lt;</FONT><A=20
href=3D"mailto:marcogatto@inwind.it"><FONT=20
size=3D2>marcogatto@inwind.it</FONT></A><FONT size=3D2>&gt; wrote in =
message=20
</FONT><A =
href=3D"news:c7545cd7.0307302247.1847258d@posting.google.com"><FONT=20
size=3D2>news:c7545cd7.0307302247.1847258d@posting.google.com</FONT></A><=
FONT=20
size=3D2>...</FONT></DIV><FONT size=3D2>&gt; Sorry Derek but I didn't =
explain very=20
well.... :)<BR>&gt; <BR>&gt; Step1 Insert New Row =
X&nbsp;&nbsp;&nbsp;&nbsp;=20
----&gt; Detached (OK)<BR>&gt; Step2 Add=20
X&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;=20
----&gt; Added&nbsp;&nbsp;&nbsp; (OK)<BR>&gt; Step3=20
AcceptChanges&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ----&gt;=20
Unchanged(OK)<BR>&gt; Step4 Set New Value (Foo2) ----&gt;=20
Unchanged(NOOO)<BR>&gt; Step5 Set New Value (Foo3) ----&gt; Modified=20
(...)<BR>&gt; <BR>&gt; Marco Gatto<BR>&gt; <BR>&gt; "Derek LaZard" =
&lt;</FONT><A=20
href=3D"mailto:derekll@mindspring.com"><FONT=20
size=3D2>derekll@mindspring.com</FONT></A><FONT size=3D2>&gt; wrote in =
message=20
</FONT><A href=3D"news:<ehE97AtVDHA.532@TK2MSFTNGP10.phx.gbl"><FONT=20
size=3D2>news:&lt;ehE97AtVDHA.532@TK2MSFTNGP10.phx.gbl</FONT></A><FONT=20
size=3D2>&gt;...<BR>&gt; &gt; Hi Marco.<BR>&gt; &gt; <BR>&gt; &gt; =
&gt;&gt;after=20
an<BR>&gt; &gt; &gt;&gt;Acceptchanges() on DataTable that contains X. =
After this=20
operation<BR>&gt; &gt; &gt;&gt;DataRow.Rowstate is Unchanged... =
strange... it=20
must be Modified ..<BR>&gt; &gt; <BR>&gt; &gt; After changes are =
accepted the=20
rowstate is now Unchanged. :)<BR>&gt; &gt; [dataAdapter.Fill() and =
.Update()=20
resets the rowstates to unchanged...<BR>&gt; &gt; <BR>&gt; &gt; Derek=20
LaZard<BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; "Marco Gatto" =
&lt;</FONT><A=20
href=3D"mailto:marcogatto@inwind.it"><FONT=20
size=3D2>marcogatto@inwind.it</FONT></A><FONT size=3D2>&gt; wrote in =
message<BR>&gt;=20
&gt; </FONT><A =
href=3D"news:c7545cd7.0307290321.1f2b09b1@posting.google.com"><FONT=20
size=3D2>news:c7545cd7.0307290321.1f2b09b1@posting.google.com</FONT></A><=
FONT=20
size=3D2>...<BR>&gt; &gt; &gt; Hello Everyone<BR>&gt; &gt; &gt; I've got =
a problem=20
when I set a value into a DataRow X after an<BR>&gt; &gt; &gt; =
Acceptchanges()=20
on DataTable that contains X. After this operation<BR>&gt; &gt; &gt;=20
DataRow.Rowstate is Unchanged... strange... it must be Modified =
..<BR>&gt; &gt;=20
&gt; isn't it?<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; I =
you see=20
the following code (just "little boring"...)<BR>&gt; &gt; &gt;<BR>&gt; =
&gt; &gt;=20
Public Class testclass<BR>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; =
Protected=20
mDataTable As Data.DataTable<BR>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; =
Protected=20
mRow As Data.DataRow<BR>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; Protected =

mDataAdapter As SqlClient.SqlDataAdapter<BR>&gt; &gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp; Protected mConn As =
SqlClient.SqlConnection<BR>&gt;=20
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; '----------------------------<BR>&gt; =
&gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp; ' New<BR>&gt; &gt; =
&gt;&nbsp;&nbsp;&nbsp;&nbsp;=20
'----------------------------<BR>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; =
Public=20
Sub New()<BR>&gt; &gt; =
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
mDataTable =3D New Data.DataTable()<BR>&gt; &gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mConn =3D New=20
SqlClient.SqlConnection("Data<BR>&gt; &gt; &gt; =
Source=3Dtest-srv;Integrated=20
Security=3DSSPI;Initial Catalog=3DTest")<BR>&gt; &gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mDataAdapter =3D =
New=20
SqlClient.SqlDataAdapter("SELECT ID,<BR>&gt; &gt; &gt; Descrizione FROM =
Table",=20
mConn)<BR>&gt; &gt; &gt;<BR>&gt; &gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
mDataAdapter.FillSchema(mDataTable, SchemaType.Mapped)<BR>&gt; &gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mRow =3D=20
mDataTable.NewRow()<BR>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; End =
Sub<BR>&gt;=20
&gt; &gt;<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; =
Public Sub=20
Insert()<BR>&gt; &gt; =
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If=20
mRow.RowState &lt;&gt; DataRowState.Detached Then Exit Sub<BR>&gt; &gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mRow(0) =3D=20
"c51ac21a-05bc-475c-ad75-1affd8f980c3"<BR>&gt; &gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mRow(1) =3D =
"Hello!!"<BR>&gt;=20
&gt; &gt;<BR>&gt; &gt; =
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
'--------------------------------------------<BR>&gt; &gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' Delete evenually =
records=20
from DataTable<BR>&gt; &gt; =
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
'--------------------------------------------<BR>&gt; &gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
mDataTable.Clear()<BR>&gt;=20
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
'-----------------------------------------<BR>&gt; &gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' AddRow<BR>&gt; =
&gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
'-----------------------------------------<BR>&gt; &gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
mDataTable.Rows.Add(mRow)<BR>&gt; &gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
Debug.WriteLine(mRow.RowState)<BR>&gt; &gt; &gt;<BR>&gt; &gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
'---------------------------<BR>&gt; &gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Accept<BR>&gt; =
&gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
'----------------------------<BR>&gt; &gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
mDataTable.AcceptChanges()<BR>&gt; &gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Debug.WriteLine(mRow(1,=20
DataRowVersion.Original) &amp; " " &amp;<BR>&gt; &gt; &gt; mRow(1,=20
DataRowVersion.Current) &amp; " " &amp; mRow.RowState)<BR>&gt; &gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
'----------------------------------------<BR>&gt; &gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' Try to change =
value=20
BUT!!!!!<BR>&gt; &gt; =
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
'----------------------------------------<BR>&gt; &gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mRow(1) =3D =
"Foo2"<BR>&gt;=20
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
Debug.WriteLine(mRow(1, DataRowVersion.Original) &amp; " " &amp;<BR>&gt; =
&gt;=20
&gt; mRow(1, DataRowVersion.Current) &amp; " " &amp; =
mRow.RowState)<BR>&gt; &gt;=20
&gt;<BR>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
mRow(1) =3D=20
"Foo3"<BR>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =

Debug.WriteLine(mRow(1, DataRowVersion.Original) &amp; " " &amp;<BR>&gt; =
&gt;=20
&gt; mRow(1, DataRowVersion.Current) &amp; " " &amp; =
mRow.RowState)<BR>&gt; &gt;=20
&gt;<BR>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; End Sub<BR>&gt; &gt; =
&gt;<BR>&gt;=20
&gt; &gt; AND CLIENT USER...<BR>&gt; &gt; &gt;<BR>&gt; &gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp; Private Sub Button1_Click(ByVal sender As=20
System.Object, ByVal e<BR>&gt; &gt; &gt; As System.EventArgs) Handles=20
Button1.Click<BR>&gt; &gt; =
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
Dim trow As New testclass()<BR>&gt; &gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
trow.Insert()<BR>&gt; &gt;=20
&gt;<BR>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; End Sub<BR>&gt; &gt; =
&gt;<BR>&gt;=20
&gt; &gt; End Class<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt;<BR>&gt; &gt; =
&gt; You=20
can see that after AcceptChanges is all ok... (Rowstate=3D<BR>&gt; &gt; =
&gt;=20
Unchanged) but when I set:<BR>&gt; &gt;=20
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mRow(1) =3D =
"Foo2"<BR>&gt;=20
&gt; &gt;<BR>&gt; &gt; &gt; mRow.rowstate remains Unchanged....<BR>&gt; =
&gt;=20
&gt;<BR>&gt; &gt; &gt; Please Help me!!<BR>&gt; &gt; &gt;<BR>&gt; &gt; =
&gt;=20
Marco Gatto</FONT> </BODY></HTML>

------=_NextPart_000_0041_01C3575A.A1D01E30--


Re: Problem With DataRow Rowstate by Derek

Derek
Thu Jul 31 11:55:19 CDT 2003

This is a multi-part message in MIME format.

------=_NextPart_000_0033_01C3575A.9D5F2F80
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Marco, BTW, I've noticed in your code listing:

mDataTable.Clear()

IMO, apparently this statement, in this sequence, is breaking internal =
links that=20
mDataTable.NewRow() sets up-- .Clear() removes the row from the =
DataTable, and
at least removes some of the internal plumbing (events, etc.) that =
.NewRow() makes for rows in a DataTable--.Clear() reverses .NewRow()... =


Have you check this in the debugger? I have for the C# translation...

The code sequence should always be something like the following:=20

...
aDataRow =3D .NewRow()

//(optional processing)...edits, checks/validation...=20

.Add( aDataRow);
...

What do you think?

Derek LaZard

"Marco Gatto" <marcogatto@inwind.it> wrote in message =
news:c7545cd7.0307302247.1847258d@posting.google.com...
> Sorry Derek but I didn't explain very well.... :)
>=20
> Step1 Insert New Row X ----> Detached (OK)
> Step2 Add X ----> Added (OK)
> Step3 AcceptChanges ----> Unchanged(OK)
> Step4 Set New Value (Foo2) ----> Unchanged(NOOO)
> Step5 Set New Value (Foo3) ----> Modified (...)
>=20
> Marco Gatto
>=20
> "Derek LaZard" <derekll@mindspring.com> wrote in message =
news:<ehE97AtVDHA.532@TK2MSFTNGP10.phx.gbl>...
> > Hi Marco.
> >=20
> > >>after an
> > >>Acceptchanges() on DataTable that contains X. After this operation
> > >>DataRow.Rowstate is Unchanged... strange... it must be Modified ..
> >=20
> > After changes are accepted the rowstate is now Unchanged. :)
> > [dataAdapter.Fill() and .Update() resets the rowstates to =
unchanged...
> >=20
> > Derek LaZard
> >=20
> >=20
> > "Marco Gatto" <marcogatto@inwind.it> wrote in message
> > news:c7545cd7.0307290321.1f2b09b1@posting.google.com...
> > > Hello Everyone
> > > I've got a problem when I set a value into a DataRow X after an
> > > Acceptchanges() on DataTable that contains X. After this operation
> > > DataRow.Rowstate is Unchanged... strange... it must be Modified ..
> > > isn't it?
> > >
> > >
> > > I you see the following code (just "little boring"...)
> > >
> > > Public Class testclass
> > > Protected mDataTable As Data.DataTable
> > > Protected mRow As Data.DataRow
> > > Protected mDataAdapter As SqlClient.SqlDataAdapter
> > > Protected mConn As SqlClient.SqlConnection
> > > '----------------------------
> > > ' New
> > > '----------------------------
> > > Public Sub New()
> > > mDataTable =3D New Data.DataTable()
> > > mConn =3D New SqlClient.SqlConnection("Data
> > > Source=3Dtest-srv;Integrated Security=3DSSPI;Initial =
Catalog=3DTest")
> > > mDataAdapter =3D New SqlClient.SqlDataAdapter("SELECT ID,
> > > Descrizione FROM Table", mConn)
> > >
> > > mDataAdapter.FillSchema(mDataTable, SchemaType.Mapped)
> > > mRow =3D mDataTable.NewRow()
> > > End Sub
> > >
> > >
> > > Public Sub Insert()
> > > If mRow.RowState <> DataRowState.Detached Then Exit Sub
> > > mRow(0) =3D "c51ac21a-05bc-475c-ad75-1affd8f980c3"
> > > mRow(1) =3D "Hello!!"
> > >
> > > '--------------------------------------------
> > > ' Delete evenually records from DataTable
> > > '--------------------------------------------
> > > mDataTable.Clear()
> > > '-----------------------------------------
> > > ' AddRow
> > > '-----------------------------------------
> > > mDataTable.Rows.Add(mRow)
> > > Debug.WriteLine(mRow.RowState)
> > >
> > > '---------------------------
> > > 'Accept
> > > '----------------------------
> > > mDataTable.AcceptChanges()
> > > Debug.WriteLine(mRow(1, DataRowVersion.Original) & " " &
> > > mRow(1, DataRowVersion.Current) & " " & mRow.RowState)
> > > '----------------------------------------
> > > ' Try to change value BUT!!!!!
> > > '----------------------------------------
> > > mRow(1) =3D "Foo2"
> > > Debug.WriteLine(mRow(1, DataRowVersion.Original) & " " &
> > > mRow(1, DataRowVersion.Current) & " " & mRow.RowState)
> > >
> > > mRow(1) =3D "Foo3"
> > > Debug.WriteLine(mRow(1, DataRowVersion.Original) & " " &
> > > mRow(1, DataRowVersion.Current) & " " & mRow.RowState)
> > >
> > > End Sub
> > >
> > > AND CLIENT USER...
> > >
> > > Private Sub Button1_Click(ByVal sender As System.Object, ByVal =
e
> > > As System.EventArgs) Handles Button1.Click
> > > Dim trow As New testclass()
> > > trow.Insert()
> > >
> > > End Sub
> > >
> > > End Class
> > >
> > >
> > > You can see that after AcceptChanges is all ok... (Rowstate=3D
> > > Unchanged) but when I set:
> > > mRow(1) =3D "Foo2"
> > >
> > > mRow.rowstate remains Unchanged....
> > >
> > > Please Help me!!
> > >
> > > Marco Gatto
------=_NextPart_000_0033_01C3575A.9D5F2F80
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1106" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Marco, BTW, I've noticed in your code =
listing:</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>mDataTable.<STRONG>Clear</STRONG>()</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>IMO, apparently this statement, in this sequence, is =
breaking=20
internal links that </FONT></DIV>
<DIV><FONT size=3D2>mDataTable.<STRONG>NewRow</STRONG>() sets up--=20
.<STRONG>Clear</STRONG>() <U><EM>removes the row</EM></U> from the =
DataTable,=20
and</FONT></DIV>
<DIV><FONT size=3D2>at least removes some of the internal plumbing =
(events, etc.)=20
&nbsp;that <STRONG>.NewRow</STRONG>() makes&nbsp;for&nbsp;rows in a=20
DataTable--.Clear() reverses .NewRow()...&nbsp; </FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Have you check this in the debugger?&nbsp; I have =
for the C#=20
translation...</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>The code sequence should always be something like =
the=20
following: </FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>...</FONT></DIV>
<DIV><FONT size=3D2>aDataRow =3D .NewRow()</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>//(optional processing)...edits, =
checks/validation...=20
</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>.Add( aDataRow);</FONT></DIV>
<DIV><FONT size=3D2>...<BR></FONT></DIV>
<DIV><FONT size=3D2>What do you think?</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;</DIV></FONT>
<DIV><FONT size=3D2>Derek LaZard</DIV></FONT>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>"Marco Gatto" &lt;</FONT><A=20
href=3D"mailto:marcogatto@inwind.it"><FONT=20
size=3D2>marcogatto@inwind.it</FONT></A><FONT size=3D2>&gt; wrote in =
message=20
</FONT><A =
href=3D"news:c7545cd7.0307302247.1847258d@posting.google.com"><FONT=20
size=3D2>news:c7545cd7.0307302247.1847258d@posting.google.com</FONT></A><=
FONT=20
size=3D2>...</FONT></DIV><FONT size=3D2>&gt; Sorry Derek but I didn't =
explain very=20
well.... :)<BR>&gt; <BR>&gt; Step1 Insert New Row =
X&nbsp;&nbsp;&nbsp;&nbsp;=20
----&gt; Detached (OK)<BR>&gt; Step2 Add=20
X&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;=20
----&gt; Added&nbsp;&nbsp;&nbsp; (OK)<BR>&gt; Step3=20
AcceptChanges&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ----&gt;=20
Unchanged(OK)<BR>&gt; Step4 Set New Value (Foo2) ----&gt;=20
Unchanged(NOOO)<BR>&gt; Step5 Set New Value (Foo3) ----&gt; Modified=20
(...)<BR>&gt; <BR>&gt; Marco Gatto<BR>&gt; <BR>&gt; "Derek LaZard" =
&lt;</FONT><A=20
href=3D"mailto:derekll@mindspring.com"><FONT=20
size=3D2>derekll@mindspring.com</FONT></A><FONT size=3D2>&gt; wrote in =
message=20
</FONT><A href=3D"news:<ehE97AtVDHA.532@TK2MSFTNGP10.phx.gbl"><FONT=20
size=3D2>news:&lt;ehE97AtVDHA.532@TK2MSFTNGP10.phx.gbl</FONT></A><FONT=20
size=3D2>&gt;...<BR>&gt; &gt; Hi Marco.<BR>&gt; &gt; <BR>&gt; &gt; =
&gt;&gt;after=20
an<BR>&gt; &gt; &gt;&gt;Acceptchanges() on DataTable that contains X. =
After this=20
operation<BR>&gt; &gt; &gt;&gt;DataRow.Rowstate is Unchanged... =
strange... it=20
must be Modified ..<BR>&gt; &gt; <BR>&gt; &gt; After changes are =
accepted the=20
rowstate is now Unchanged. :)<BR>&gt; &gt; [dataAdapter.Fill() and =
.Update()=20
resets the rowstates to unchanged...<BR>&gt; &gt; <BR>&gt; &gt; Derek=20
LaZard<BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; "Marco Gatto" =
&lt;</FONT><A=20
href=3D"mailto:marcogatto@inwind.it"><FONT=20
size=3D2>marcogatto@inwind.it</FONT></A><FONT size=3D2>&gt; wrote in =
message<BR>&gt;=20
&gt; </FONT><A =
href=3D"news:c7545cd7.0307290321.1f2b09b1@posting.google.com"><FONT=20
size=3D2>news:c7545cd7.0307290321.1f2b09b1@posting.google.com</FONT></A><=
FONT=20
size=3D2>...<BR>&gt; &gt; &gt; Hello Everyone<BR>&gt; &gt; &gt; I've got =
a problem=20
when I set a value into a DataRow X after an<BR>&gt; &gt; &gt; =
Acceptchanges()=20
on DataTable that contains X. After this operation<BR>&gt; &gt; &gt;=20
DataRow.Rowstate is Unchanged... strange... it must be Modified =
..<BR>&gt; &gt;=20
&gt; isn't it?<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; I =
you see=20
the following code (just "little boring"...)<BR>&gt; &gt; &gt;<BR>&gt; =
&gt; &gt;=20
Public Class testclass<BR>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; =
Protected=20
mDataTable As Data.DataTable<BR>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; =
Protected=20
mRow As Data.DataRow<BR>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; Protected =