Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / August 2005

Tip: Looking for answers? Try searching our database.

HasChanges does not change even after EndCurrentEdit() is called HELP!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mqasem@gmail.com - 30 Aug 2005 22:36 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.