Greetings,

I have a textbox control with has a binding to a DataView
(which always has only one row). Changes to the row are
persisted during the lifetime of the DataSet/DataTable
which underlies the DataView. However when I use
MyDataAdaptor.update() the change is ignored. When I
programmatically inspect data in the row, I see the new
value, but when I look ats it rowstate this is set
to "unchanged".

Further info:

if I use editbegin() and editend() the rowstate is changed
to modified. Update then catches the change and updates
the database.

The DataView is being used to filter to a single record to
supply a form (sorting on an index value of another
control). So the filter is being changed frequently before
Update is called. However the changes persist when rows
are revisited.

I have another textbox control on the same form, using a
different dataview - changes to it are caught and passed
on to the update. I see no differences in the properties
of the controls or the dataveiws.

I don't think this matters but the data type of the column
in the database is int, while the textbox is string.

Any ideas?

Re: DataView not writing changes to DataSet???? by Marina

Marina
Mon Aug 18 14:18:27 CDT 2003

You need to show the relevant code...

You are not calling AcceptChanges are you?

"twsmith" <worldviewtws@msn.com> wrote in message
news:043d01c365bc$c44f1540$a101280a@phx.gbl...
> Greetings,
>
> I have a textbox control with has a binding to a DataView
> (which always has only one row). Changes to the row are
> persisted during the lifetime of the DataSet/DataTable
> which underlies the DataView. However when I use
> MyDataAdaptor.update() the change is ignored. When I
> programmatically inspect data in the row, I see the new
> value, but when I look ats it rowstate this is set
> to "unchanged".
>
> Further info:
>
> if I use editbegin() and editend() the rowstate is changed
> to modified. Update then catches the change and updates
> the database.
>
> The DataView is being used to filter to a single record to
> supply a form (sorting on an index value of another
> control). So the filter is being changed frequently before
> Update is called. However the changes persist when rows
> are revisited.
>
> I have another textbox control on the same form, using a
> different dataview - changes to it are caught and passed
> on to the update. I see no differences in the properties
> of the controls or the dataveiws.
>
> I don't think this matters but the data type of the column
> in the database is int, while the textbox is string.
>
> Any ideas?
>
>



Re: DataView not writing changes to DataSet???? by twsmith

twsmith
Mon Aug 18 14:53:44 CDT 2003

Maria, thanks for looking, there is not much code - most
of the below is testing with comments




Declaration Code


DataTable dtEvent = ds.Tables["tblEvent"];
DVEventInfo = new DataView(dtEvent);
DVEventInfo.AllowDelete=true;
DVEventInfo.AllowEdit=true;
DVEventInfo.AllowNew=true;


this.txtFrom.DataBindings.Add("Text",DVEventInfo,"efrom");
__________________________

private void cmdSaveAndExit_Click(object sender,
System.EventArgs e)

try
{
DVEventInfo.RowFilter="";

//test row
//note:*** the value is changed
//*** but RowState reads "unchanged"
//attempt to update returns a '0'
// changes not sent to database
foreach (DataRowView dr in DVEventInfo)
{
Console.WriteLine(dr[2].ToString());
Console.WriteLine(dr.Row.RowState);
}

//test update command
SqlCommandBuilder sqkCBEvent = new SqlCommandBuilder
(daEvent);
//test
Console.WriteLine(sqkCBEvent.GetUpdateCommand
().CommandText);
Console.WriteLine(this.daEvent.Update(ds,"tblEvent"));
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
this.ParentForm.Close();
}




>-----Original Message-----
>You need to show the relevant code...
>
>You are not calling AcceptChanges are you?
>
>"twsmith" <worldviewtws@msn.com> wrote in message
>news:043d01c365bc$c44f1540$a101280a@phx.gbl...
>> Greetings,
>>
>> I have a textbox control with has a binding to a
DataView
>> (which always has only one row). Changes to the row are
>> persisted during the lifetime of the DataSet/DataTable
>> which underlies the DataView. However when I use
>> MyDataAdaptor.update() the change is ignored. When I
>> programmatically inspect data in the row, I see the new
>> value, but when I look ats it rowstate this is set
>> to "unchanged".
>>
>> Further info:
>>
>> if I use editbegin() and editend() the rowstate is
changed
>> to modified. Update then catches the change and updates
>> the database.
>>
>> The DataView is being used to filter to a single record
to
>> supply a form (sorting on an index value of another
>> control). So the filter is being changed frequently
before
>> Update is called. However the changes persist when rows
>> are revisited.
>>
>> I have another textbox control on the same form, using a
>> different dataview - changes to it are caught and passed
>> on to the update. I see no differences in the properties
>> of the controls or the dataveiws.
>>
>> I don't think this matters but the data type of the
column
>> in the database is int, while the textbox is string.
>>
>> Any ideas?
>>
>>
>
>
>.
>

Re: DataView not writing changes to DataSet???? by Marina

Marina
Mon Aug 18 15:07:18 CDT 2003

Have you tried looking directly through the dataset, not the dataview?

"twsmith" <worldviewtws@msn.com> wrote in message
news:033801c365c2$6e28e320$a401280a@phx.gbl...
> Maria, thanks for looking, there is not much code - most
> of the below is testing with comments
>
>
>
>
> Declaration Code
>
>
> DataTable dtEvent = ds.Tables["tblEvent"];
> DVEventInfo = new DataView(dtEvent);
> DVEventInfo.AllowDelete=true;
> DVEventInfo.AllowEdit=true;
> DVEventInfo.AllowNew=true;
>
>
> this.txtFrom.DataBindings.Add("Text",DVEventInfo,"efrom");
> __________________________
>
> private void cmdSaveAndExit_Click(object sender,
> System.EventArgs e)
>
> try
> {
> DVEventInfo.RowFilter="";
>
> //test row
> //note:*** the value is changed
> //*** but RowState reads "unchanged"
> //attempt to update returns a '0'
> // changes not sent to database
> foreach (DataRowView dr in DVEventInfo)
> {
> Console.WriteLine(dr[2].ToString());
> Console.WriteLine(dr.Row.RowState);
> }
>
> //test update command
> SqlCommandBuilder sqkCBEvent = new SqlCommandBuilder
> (daEvent);
> //test
> Console.WriteLine(sqkCBEvent.GetUpdateCommand
> ().CommandText);
> Console.WriteLine(this.daEvent.Update(ds,"tblEvent"));
> }
> catch(Exception ex)
> {
> MessageBox.Show(ex.Message);
> }
> this.ParentForm.Close();
> }
>
>
>
>
> >-----Original Message-----
> >You need to show the relevant code...
> >
> >You are not calling AcceptChanges are you?
> >
> >"twsmith" <worldviewtws@msn.com> wrote in message
> >news:043d01c365bc$c44f1540$a101280a@phx.gbl...
> >> Greetings,
> >>
> >> I have a textbox control with has a binding to a
> DataView
> >> (which always has only one row). Changes to the row are
> >> persisted during the lifetime of the DataSet/DataTable
> >> which underlies the DataView. However when I use
> >> MyDataAdaptor.update() the change is ignored. When I
> >> programmatically inspect data in the row, I see the new
> >> value, but when I look ats it rowstate this is set
> >> to "unchanged".
> >>
> >> Further info:
> >>
> >> if I use editbegin() and editend() the rowstate is
> changed
> >> to modified. Update then catches the change and updates
> >> the database.
> >>
> >> The DataView is being used to filter to a single record
> to
> >> supply a form (sorting on an index value of another
> >> control). So the filter is being changed frequently
> before
> >> Update is called. However the changes persist when rows
> >> are revisited.
> >>
> >> I have another textbox control on the same form, using a
> >> different dataview - changes to it are caught and passed
> >> on to the update. I see no differences in the properties
> >> of the controls or the dataveiws.
> >>
> >> I don't think this matters but the data type of the
> column
> >> in the database is int, while the textbox is string.
> >>
> >> Any ideas?
> >>
> >>
> >
> >
> >.
> >



Re: DataView not writing changes to DataSet???? by twsmith

twsmith
Mon Aug 18 16:36:24 CDT 2003

Ok, I see your point - isolate the problem to the dataset-
dataadapter step. I will inspect that tonight.

I can tell you this however if I add

dr.BeginEdit();
dr[2]=1699;
dr.EndEdit();

to my

foreach (DataRowView dr in DVEventInfo)
{

dr.BeginEdit();
dr[2]=1699;
dr.EndEdit();
Console.WriteLine(dr[2].ToString());
Console.WriteLine(dr.RowVersion);
Console.WriteLine(dr.Row.RowState);
}

then the RowState reads as "Modified" and the
dataAdaptor.Update catches it and updates the database
with new value. So it seems to me that somehow the change
in the text box is not triggering a flip of the RowState.




>-----Original Message-----
>Have you tried looking directly through the dataset, not
the dataview?
>
>"twsmith" <worldviewtws@msn.com> wrote in message
>news:033801c365c2$6e28e320$a401280a@phx.gbl...
>> Maria, thanks for looking, there is not much code - most
>> of the below is testing with comments
>>
>>
>>
>>
>> Declaration Code
>>
>>
>> DataTable dtEvent = ds.Tables["tblEvent"];
>> DVEventInfo = new DataView(dtEvent);
>> DVEventInfo.AllowDelete=true;
>> DVEventInfo.AllowEdit=true;
>> DVEventInfo.AllowNew=true;
>>
>>
>> this.txtFrom.DataBindings.Add
("Text",DVEventInfo,"efrom");
>> __________________________
>>
>> private void cmdSaveAndExit_Click(object sender,
>> System.EventArgs e)
>>
>> try
>> {
>> DVEventInfo.RowFilter="";
>>
>> //test row
>> //note:*** the value is changed
>> //*** but RowState reads "unchanged"
>> //attempt to update returns a '0'
>> // changes not sent to database
>> foreach (DataRowView dr in DVEventInfo)
>> {
>> Console.WriteLine(dr[2].ToString());
>> Console.WriteLine(dr.Row.RowState);
>> }
>>
>> //test update command
>> SqlCommandBuilder sqkCBEvent = new SqlCommandBuilder
>> (daEvent);
>> //test
>> Console.WriteLine(sqkCBEvent.GetUpdateCommand
>> ().CommandText);
>> Console.WriteLine(this.daEvent.Update(ds,"tblEvent"));
>> }
>> catch(Exception ex)
>> {
>> MessageBox.Show(ex.Message);
>> }
>> this.ParentForm.Close();
>> }
>>
>>
>>
>>
>> >-----Original Message-----
>> >You need to show the relevant code...
>> >
>> >You are not calling AcceptChanges are you?
>> >
>> >"twsmith" <worldviewtws@msn.com> wrote in message
>> >news:043d01c365bc$c44f1540$a101280a@phx.gbl...
>> >> Greetings,
>> >>
>> >> I have a textbox control with has a binding to a
>> DataView
>> >> (which always has only one row). Changes to the row
are
>> >> persisted during the lifetime of the
DataSet/DataTable
>> >> which underlies the DataView. However when I use
>> >> MyDataAdaptor.update() the change is ignored. When I
>> >> programmatically inspect data in the row, I see the
new
>> >> value, but when I look ats it rowstate this is set
>> >> to "unchanged".
>> >>
>> >> Further info:
>> >>
>> >> if I use editbegin() and editend() the rowstate is
>> changed
>> >> to modified. Update then catches the change and
updates
>> >> the database.
>> >>
>> >> The DataView is being used to filter to a single
record
>> to
>> >> supply a form (sorting on an index value of another
>> >> control). So the filter is being changed frequently
>> before
>> >> Update is called. However the changes persist when
rows
>> >> are revisited.
>> >>
>> >> I have another textbox control on the same form,
using a
>> >> different dataview - changes to it are caught and
passed
>> >> on to the update. I see no differences in the
properties
>> >> of the controls or the dataveiws.
>> >>
>> >> I don't think this matters but the data type of the
>> column
>> >> in the database is int, while the textbox is string.
>> >>
>> >> Any ideas?
>> >>
>> >>
>> >
>> >
>> >.
>> >
>
>
>.
>

DataView not writing changes to DataSet???? by Puspak

Puspak
Tue Aug 19 02:46:32 CDT 2003

I must admit that I didn't look into it very deeply, but
I had a similar problem, in my case, the control on the
form was bound to a column of a datatable. I had to call
the relevant currency manager's EndCurrentEdit method
before it could see the row as being modified. After that
when I called the data adapter's 'update' method, it
worked.
Let me know if it helped you.

>-----Original Message-----
>Greetings,
>
>I have a textbox control with has a binding to a
DataView
>(which always has only one row). Changes to the row are
>persisted during the lifetime of the DataSet/DataTable
>which underlies the DataView. However when I use
>MyDataAdaptor.update() the change is ignored. When I
>programmatically inspect data in the row, I see the new
>value, but when I look ats it rowstate this is set
>to "unchanged".
>
>Further info:
>
>if I use editbegin() and editend() the rowstate is
changed
>to modified. Update then catches the change and updates
>the database.
>
>The DataView is being used to filter to a single record
to
>supply a form (sorting on an index value of another
>control). So the filter is being changed frequently
before
>Update is called. However the changes persist when rows
>are revisited.
>
>I have another textbox control on the same form, using a
>different dataview - changes to it are caught and passed
>on to the update. I see no differences in the properties
>of the controls or the dataveiws.
>
>I don't think this matters but the data type of the
column
>in the database is int, while the textbox is string.
>
>Any ideas?
>
>
>.
>

Re: DataView not writing changes to DataSet???? by twsmith

twsmith
Tue Aug 19 08:11:31 CDT 2003

I did inspect that the table directly in the data set. The
situation is the same - the value is changed in the table,
the Rowstate remains unchanged and the dataadapter
returns '0' indicating that no rows changes were detected.

DataTable tempTbl = new DataTable();
int intCounter;
intCounter=0;
tempTbl = ds.Tables["tblEvent"];

foreach(DataRow tempDR in tempTbl.Rows)
{
intCounter++;
Console.WriteLine("line: {0}",intCounter);
Console.WriteLine(tempDR[2].ToString());
Console.WriteLine(tempDR.RowState.ToString());
}

So, does this mean my problem is with the update logic
(recall that I am using the commands generated by the
adaptor). No error is thrown and everything looks fine to
me.

Any thing else I should check?

in a parallel email I also noted that:

dr.BeginEdit();
dr[2]=1699;
dr.EndEdit();

to my

foreach (DataRowView dr in DVEventInfo)
{

dr.BeginEdit();
dr[2]=1699;
dr.EndEdit();
Console.WriteLine(dr[2].ToString());
Console.WriteLine(dr.RowVersion);
Console.WriteLine(dr.Row.RowState);
}

then the RowState reads as "Modified" and the
dataAdaptor.Update catches it and updates the database
with new value. So it seems to me that somehow the change
in the text box is not triggering a flip of the RowState.


Tim




>-----Original Message-----
>Have you tried looking directly through the dataset, not
the dataview?
>
>"twsmith" <worldviewtws@msn.com> wrote in message
>news:033801c365c2$6e28e320$a401280a@phx.gbl...
>> Maria, thanks for looking, there is not much code - most
>> of the below is testing with comments
>>
>>
>>
>>
>> Declaration Code
>>
>>
>> DataTable dtEvent = ds.Tables["tblEvent"];
>> DVEventInfo = new DataView(dtEvent);
>> DVEventInfo.AllowDelete=true;
>> DVEventInfo.AllowEdit=true;
>> DVEventInfo.AllowNew=true;
>>
>>
>> this.txtFrom.DataBindings.Add
("Text",DVEventInfo,"efrom");
>> __________________________
>>
>> private void cmdSaveAndExit_Click(object sender,
>> System.EventArgs e)
>>
>> try
>> {
>> DVEventInfo.RowFilter="";
>>
>> //test row
>> //note:*** the value is changed
>> //*** but RowState reads "unchanged"
>> //attempt to update returns a '0'
>> // changes not sent to database
>> foreach (DataRowView dr in DVEventInfo)
>> {
>> Console.WriteLine(dr[2].ToString());
>> Console.WriteLine(dr.Row.RowState);
>> }
>>
>> //test update command
>> SqlCommandBuilder sqkCBEvent = new SqlCommandBuilder
>> (daEvent);
>> //test
>> Console.WriteLine(sqkCBEvent.GetUpdateCommand
>> ().CommandText);
>> Console.WriteLine(this.daEvent.Update(ds,"tblEvent"));
>> }
>> catch(Exception ex)
>> {
>> MessageBox.Show(ex.Message);
>> }
>> this.ParentForm.Close();
>> }
>>
>>
>>
>>
>> >-----Original Message-----
>> >You need to show the relevant code...
>> >
>> >You are not calling AcceptChanges are you?
>> >
>> >"twsmith" <worldviewtws@msn.com> wrote in message
>> >news:043d01c365bc$c44f1540$a101280a@phx.gbl...
>> >> Greetings,
>> >>
>> >> I have a textbox control with has a binding to a
>> DataView
>> >> (which always has only one row). Changes to the row
are
>> >> persisted during the lifetime of the
DataSet/DataTable
>> >> which underlies the DataView. However when I use
>> >> MyDataAdaptor.update() the change is ignored. When I
>> >> programmatically inspect data in the row, I see the
new
>> >> value, but when I look ats it rowstate this is set
>> >> to "unchanged".
>> >>
>> >> Further info:
>> >>
>> >> if I use editbegin() and editend() the rowstate is
>> changed
>> >> to modified. Update then catches the change and
updates
>> >> the database.
>> >>
>> >> The DataView is being used to filter to a single
record
>> to
>> >> supply a form (sorting on an index value of another
>> >> control). So the filter is being changed frequently
>> before
>> >> Update is called. However the changes persist when
rows
>> >> are revisited.
>> >>
>> >> I have another textbox control on the same form,
using a
>> >> different dataview - changes to it are caught and
passed
>> >> on to the update. I see no differences in the
properties
>> >> of the controls or the dataveiws.
>> >>
>> >> I don't think this matters but the data type of the
>> column
>> >> in the database is int, while the textbox is string.
>> >>
>> >> Any ideas?
>> >>
>> >>
>> >
>> >
>> >.
>> >
>
>
>.
>

DataView not writing changes to DataSet???? by twsmith

twsmith
Wed Aug 20 10:22:40 CDT 2003

Puspak, thanks for you interest. I will try that and
report back.

I doubt this is it though. I have another textbox control
on the same form bound to a different table and it updates
fine - none of the code is different. So I think there
must be a problem with the update logic.

>-----Original Message-----
>I must admit that I didn't look into it very deeply, but
>I had a similar problem, in my case, the control on the
>form was bound to a column of a datatable. I had to call
>the relevant currency manager's EndCurrentEdit method
>before it could see the row as being modified. After that
>when I called the data adapter's 'update' method, it
>worked.
>Let me know if it helped you.
>
>>-----Original Message-----
>>Greetings,
>>
>>I have a textbox control with has a binding to a
>DataView
>>(which always has only one row). Changes to the row are
>>persisted during the lifetime of the DataSet/DataTable
>>which underlies the DataView. However when I use
>>MyDataAdaptor.update() the change is ignored. When I
>>programmatically inspect data in the row, I see the new
>>value, but when I look ats it rowstate this is set
>>to "unchanged".
>>
>>Further info:
>>
>>if I use editbegin() and editend() the rowstate is
>changed
>>to modified. Update then catches the change and updates
>>the database.
>>
>>The DataView is being used to filter to a single record
>to
>>supply a form (sorting on an index value of another
>>control). So the filter is being changed frequently
>before
>>Update is called. However the changes persist when rows
>>are revisited.
>>
>>I have another textbox control on the same form, using a
>>different dataview - changes to it are caught and passed
>>on to the update. I see no differences in the properties
>>of the controls or the dataveiws.
>>
>>I don't think this matters but the data type of the
>column
>>in the database is int, while the textbox is string.
>>
>>Any ideas?
>>
>>
>>.
>>
>.
>