I am losing my mind. I can't figure this out. I have a dataset and a
textbox that is bound to it. I edit the textbox value and click a
button to submit the changes to SQL CE server. I call EndCurrentEdit(),
and then I check the value of HasChanges(). I always get a false. What
am I doing wrong?
Here is the trimmed down version of the code. Please don't worry about
the data adapter and changes to the DB. If I can get the HasChanges to
work, then I think the data adapter will also work.
------------Begining of Code------------
' In my form load
sqlCnn = New SqlCeConnection("Data Source=" & mPath & file & ";
Password=;")
sqlCnn.Open()
sqlCmdText = "Select * from TblClasses where termKeyID = 1
Order by class"
sqlCmd = New SqlCeCommand(sqlCmdText, sqlCnn)
da.SelectCommand = sqlCmd
sqlCmdBld = New SqlCeCommandBuilder(da)
da.UpdateCommand = sqlCmdBld.GetUpdateCommand
da.InsertCommand = sqlCmdBld.GetInsertCommand
da.DeleteCommand = sqlCmdBld.GetDeleteCommand
da.Fill(ds, "TblClasses")
TextBox1.DataBindings.Add("Text", ds.Tables("TblClasses"),
"class")
' End of Form
' My Button even
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
TextBox1.BindingContext(ds).EndCurrentEdit()
MessageBox.Show(ds.HasChanges())
End Sub
------------End of Code------------
I edit the text box, and click the button.
The messagebox.Show(ds.HasChanges()) always returns a false. I can't
get it work no matter what I do.
Please HEEEELP!
Ilya Tumanov [MS] - 30 Aug 2005 23:10 GMT
You're probably hitting wrong BindingManagerBase as DataSet and DataTable in
it are not the same:
TextBox1.DataBindings.Add("Text", ds.Tables("TblClasses"), "class")
____________________________^^^^^^^^^^^^^^^^^^
TextBox1.BindingContext(ds).EndCurrentEdit()
____________________^^
Best regards,
Ilya
This posting is provided "AS IS" with no warranties, and confers no rights.
*** Want to find answers instantly? Here's how... ***
1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactfra
mework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
>I am losing my mind. I can't figure this out. I have a dataset and a
> textbox that is bound to it. I edit the textbox value and click a
[quoted text clipped - 43 lines]
>
> Please HEEEELP!
Joseph Byrns - 31 Aug 2005 07:22 GMT
Also, if you end current edit like this:
Me.BindingContext(ds.Tables("TblClasses")).EndCurrentEdit()
It will work more generally, although if you only have one textbox, it's not
going to make any difference.
> You're probably hitting wrong BindingManagerBase as DataSet and DataTable
> in it are not the same:
[quoted text clipped - 67 lines]
>>
>> Please HEEEELP!
mqasem@gmail.com - 31 Aug 2005 17:50 GMT
I can't thank you guys enough. This was a huge blind spot. I spent two
nights with 4 hours each trying to get this simple code to work. Now
it's working just fine.
Moe