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 =3D New SqlCeConnection("Data Source=3D" & mPath & file & ";

Password=3D;")
sqlCnn.Open()


sqlCmdText =3D "Select * from TblClasses where termKeyID =3D 1
Order by class"
sqlCmd =3D New SqlCeCommand(sqlCmdText, sqlCnn)
da.SelectCommand =3D sqlCmd
sqlCmdBld =3D New SqlCeCommandBuilder(da)
da.UpdateCommand =3D sqlCmdBld.GetUpdateCommand
da.InsertCommand =3D sqlCmdBld.GetInsertCommand
da.DeleteCommand =3D sqlCmdBld.GetDeleteCommand


da.Fill(ds, "TblClasses")
TextBox1.DataBindings.Add("Tex=ADt", 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).En=ADdCurrentEdit()
MessageBox.Show(ds.HasChanges(=AD))
End Sub


------------End of Code------------


I edit the text box, and click the button.


The messagebox.Show(ds.HasChanges(=AD)) always returns a false. I can't
get it work no matter what I do.=20


Please HEEEELP!

Re: HasChanges does not change even after EndCurrentEdit() is called HELP! by W

W
Tue Aug 30 17:43:59 CDT 2005

I'm guessing this is on the Compact Framework Right? Ok, just for giggles,
use the AddNew or whatever technique you want to add another row and then
edit it. After adding the row, see if HasChanges is true. Also, call the
EndCurrentEdit on this/me. vs the TextBox1 unless the binding context is
different on purpose here
<mqasem@gmail.com> wrote in message
news:1125438595.518593.179550@z14g2000cwz.googlegroups.com...
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("Tex­t", 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).En­dCurrentEdit()
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!



Re: HasChanges does not change even after EndCurrentEdit() is called HELP! by Bart

Bart
Tue Aug 30 18:17:18 CDT 2005

Hi,

mqasem@gmail.com wrote:
> 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("Tex­t", 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).En­dCurrentEdit()

But you did not bind to ds, you bound to ds.Tables("TblClasses"). When
using BindingContext(...) you need to use the same DataSource as the one you
used for binding.

So, if you bind like this:

> TextBox1.DataBindings.Add("Tex­t", ds.Tables("TblClasses"), "class" )

Then you have to use:

TextBox1.BindingContext(ds.Tables("TblClasses")).En­dCurrentEdit()


HTH,
Greetings



> 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!
>