J
JohnR
I have a table with 1 row which is used to hold some application wide items
(one item per field, hence I only need 1 row).
I want to bind one of the fields to a textbox. After setting up the
oledbconnection and dataAdapter and filling the DataSet (ds) I tried this:
TextBox1.DataBindings.Add("text", ds.Tables.Item("MyFile"), "MyField")
I then put the following code in the SAVE button click event:
Dim dsChanged As DataSet = ds.GetChanges()
Try ***************** I put a
breakpoint here and examine ds.tables.item("MyFile").rows(0).rowstate
daMyFile.Update(dsChanged.Tables("MyFile"))
Catch ex As OleDbException
MsgBox(ex.ToString)
Catch ex As InvalidOperationException
MsgBox(ex.ToString)
Catch ex As DBConcurrencyException
MsgBox("concurrency exception - another user has modified this record" &
vbCr & vbLf & ex.ToString)
ds.RejectChanges()
Exit Sub
End Try
ds.AcceptChanges()
When I run the program I see the proper initial value in the textbox (this
value was obtained from the field MyField in the table MyFile), so I know
the binding is grabing the value from the right place.
However, when I change the value in the textbox and hit the SAVE button, at
the breakpoint I examine the dataset and the rowstate for the row says it is
UNCHANGED. I looked at this because I wondered why my database was not
being updated with the new value. At least I now know why the datatable
didn't change... But can anybody tell me why, when I change the value of
the textbox, the rowstate doesn't reflect the changed status???
I know I must be overlooking something simple, and if anybody can help I
would greatly appreciate it.
Thanks,
John
(one item per field, hence I only need 1 row).
I want to bind one of the fields to a textbox. After setting up the
oledbconnection and dataAdapter and filling the DataSet (ds) I tried this:
TextBox1.DataBindings.Add("text", ds.Tables.Item("MyFile"), "MyField")
I then put the following code in the SAVE button click event:
Dim dsChanged As DataSet = ds.GetChanges()
Try ***************** I put a
breakpoint here and examine ds.tables.item("MyFile").rows(0).rowstate
daMyFile.Update(dsChanged.Tables("MyFile"))
Catch ex As OleDbException
MsgBox(ex.ToString)
Catch ex As InvalidOperationException
MsgBox(ex.ToString)
Catch ex As DBConcurrencyException
MsgBox("concurrency exception - another user has modified this record" &
vbCr & vbLf & ex.ToString)
ds.RejectChanges()
Exit Sub
End Try
ds.AcceptChanges()
When I run the program I see the proper initial value in the textbox (this
value was obtained from the field MyField in the table MyFile), so I know
the binding is grabing the value from the right place.
However, when I change the value in the textbox and hit the SAVE button, at
the breakpoint I examine the dataset and the rowstate for the row says it is
UNCHANGED. I looked at this because I wondered why my database was not
being updated with the new value. At least I now know why the datatable
didn't change... But can anybody tell me why, when I change the value of
the textbox, the rowstate doesn't reflect the changed status???
I know I must be overlooking something simple, and if anybody can help I
would greatly appreciate it.
Thanks,
John