Home All Groups Group Topic Archive Search About

Does a menu item lose dataset information?

Author
4 Oct 2006 3:21 AM
Stephen Plotnick
I have two events in the same program that executes the same sub rountine;
one is from a menu item the other is from a button.

THe button works perfectly and the menu item does not.  See the code here.

From within the debugger the myDS.HasChanges allows the update to occur from
the button and the myDS.HasChanges does not allow the update to occur; as if
there are not any changes.

I am definetly doing changes in both instances.

THanks,
Steve
___________________________________
Exit button on form
___________________________________
Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ExitButton.Click

Update_Check_Rtn()

Application.Exit()

End Sub

_____________________________________________

Menu item

___________________________________________

Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MenuItem3.Click

Update_Check_Rtn()

Application.Exit()

End Sub

________________________________________

Routine called

_______________________________________

Private Sub Update_Check_Rtn()

Dim ExitResponce As Integer

If myDS.HasChanges Then

ExitResponce = MsgBox("Do you want to save your changes?", vbYesNo)

If ExitResponce = vbYes Then

Dim conn As New
System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
source='C:\Program Files\MyArea\Pricing\Pricing.mdb';Persist Security
Info=False")

Dim uSql = "Select * from ProductNames"

da.SelectCommand = New OleDb.OleDbCommand(uSql, conn)

Dim cb As New OleDb.OleDbCommandBuilder(da)

Try

myDS.Tables("ProductNames").GetChanges()

da.Update(myDS.Tables("ProductNames"))

Catch ex As Exception

MessageBox.Show(ex.ToString)

End Try

End If

End If

End Sub

Author
4 Oct 2006 3:57 AM
Cor Ligthert [MVP]
Stephen,

No a menu item does nothing with a dataset, why do you not debug your
program?

Cor

Show quoteHide quote
"Stephen Plotnick" <splotn***@groupcbf.com> schreef in bericht
news:E6udnRTEj44jtb7YnZ2dnUVZ_qmdnZ2d@giganews.com...
>I have two events in the same program that executes the same sub rountine;
>one is from a menu item the other is from a button.
>
> THe button works perfectly and the menu item does not.  See the code here.
>
> From within the debugger the myDS.HasChanges allows the update to occur
> from the button and the myDS.HasChanges does not allow the update to
> occur; as if there are not any changes.
>
> I am definetly doing changes in both instances.
>
> THanks,
> Steve
> ___________________________________
> Exit button on form
> ___________________________________
> Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles ExitButton.Click
>
> Update_Check_Rtn()
>
> Application.Exit()
>
> End Sub
>
> _____________________________________________
>
> Menu item
>
> ___________________________________________
>
> Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MenuItem3.Click
>
> Update_Check_Rtn()
>
> Application.Exit()
>
> End Sub
>
> ________________________________________
>
> Routine called
>
> _______________________________________
>
> Private Sub Update_Check_Rtn()
>
> Dim ExitResponce As Integer
>
> If myDS.HasChanges Then
>
> ExitResponce = MsgBox("Do you want to save your changes?", vbYesNo)
>
> If ExitResponce = vbYes Then
>
> Dim conn As New
> System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
> source='C:\Program Files\MyArea\Pricing\Pricing.mdb';Persist Security
> Info=False")
>
> Dim uSql = "Select * from ProductNames"
>
> da.SelectCommand = New OleDb.OleDbCommand(uSql, conn)
>
> Dim cb As New OleDb.OleDbCommandBuilder(da)
>
> Try
>
> myDS.Tables("ProductNames").GetChanges()
>
> da.Update(myDS.Tables("ProductNames"))
>
> Catch ex As Exception
>
> MessageBox.Show(ex.ToString)
>
> End Try
>
> End If
>
> End If
>
> End Sub
>
>
>
>
Author
4 Oct 2006 8:30 PM
Stephen Plotnick
I did debug it that is how I know that the changed status is incorrect from
within the menu option. Does MS know of a bug with this situation?

Steve
Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:uMs5Nk25GHA.4112@TK2MSFTNGP04.phx.gbl...
> Stephen,
>
> No a menu item does nothing with a dataset, why do you not debug your
> program?
>
> Cor
>
> "Stephen Plotnick" <splotn***@groupcbf.com> schreef in bericht
> news:E6udnRTEj44jtb7YnZ2dnUVZ_qmdnZ2d@giganews.com...
>>I have two events in the same program that executes the same sub rountine;
>>one is from a menu item the other is from a button.
>>
>> THe button works perfectly and the menu item does not.  See the code
>> here.
>>
>> From within the debugger the myDS.HasChanges allows the update to occur
>> from the button and the myDS.HasChanges does not allow the update to
>> occur; as if there are not any changes.
>>
>> I am definetly doing changes in both instances.
>>
>> THanks,
>> Steve
>> ___________________________________
>> Exit button on form
>> ___________________________________
>> Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles ExitButton.Click
>>
>> Update_Check_Rtn()
>>
>> Application.Exit()
>>
>> End Sub
>>
>> _____________________________________________
>>
>> Menu item
>>
>> ___________________________________________
>>
>> Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles MenuItem3.Click
>>
>> Update_Check_Rtn()
>>
>> Application.Exit()
>>
>> End Sub
>>
>> ________________________________________
>>
>> Routine called
>>
>> _______________________________________
>>
>> Private Sub Update_Check_Rtn()
>>
>> Dim ExitResponce As Integer
>>
>> If myDS.HasChanges Then
>>
>> ExitResponce = MsgBox("Do you want to save your changes?", vbYesNo)
>>
>> If ExitResponce = vbYes Then
>>
>> Dim conn As New
>> System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
>> source='C:\Program Files\MyArea\Pricing\Pricing.mdb';Persist Security
>> Info=False")
>>
>> Dim uSql = "Select * from ProductNames"
>>
>> da.SelectCommand = New OleDb.OleDbCommand(uSql, conn)
>>
>> Dim cb As New OleDb.OleDbCommandBuilder(da)
>>
>> Try
>>
>> myDS.Tables("ProductNames").GetChanges()
>>
>> da.Update(myDS.Tables("ProductNames"))
>>
>> Catch ex As Exception
>>
>> MessageBox.Show(ex.ToString)
>>
>> End Try
>>
>> End If
>>
>> End If
>>
>> End Sub
>>
>>
>>
>>
>
>