HasChanges not being updated?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Graham  Blandford

    #1

    HasChanges not being updated?

    Hi all,

    I'm sure I must be missing something here.. I've created a simple parent -
    child form appl. in which I open a dataset in the parent (MDI) using a
    dataadaptor to an Access database, and a dataset.

    The SELECT of the record set searches for a specific entry, if it returns a
    0 rowcount, I go throiugh the motions of adding a row, and opening the child
    form.. if it is found I just open the child form..

    I am passing the dataset through the constuctor to my child form, and if I
    use a datagrid to change the data, it marks the HasChanges correctly.
    But, as i am only dealing with one row here, and I would like to use text
    boxes for each column, I have tried to bind these in code - taken from the
    ..NET library...DataB indings entry...

    The problem is, if I change the data in a text box, (incidentally, if I
    leave the datagrid on the form, the cell appears to update for the changed
    text), the HasChanges flag is not being set to True. Is there something I
    need to code that will cause this to happen?

    Here's a snippet of the code...

    Parent form:

    With daLinkMAN_clien t_trans

    .SelectCommand. Parameters("nma n_path").Value = str_nman_path

    .Fill(dsLinkMAN )

    End With

    ' if empty then add

    If dsLinkMAN.Table s("client_trans ").Rows.Cou nt = 0 Then

    Dim dr_client_trans As DataRow

    dr_client_trans = dsLinkMAN.Table s("client_trans ").NewRow

    With dr_client_trans

    .Item("nman_pat h") = str_nman_path

    .Item("descript ion") = "New database"

    .Item("summit_c lient_id") = ""

    dsLinkMAN.Table s("client_trans ").Rows.Add(dr_ client_trans)

    End With

    End If

    ' open client form

    Dim frm As New frmClient(daLin kMAN_client_tra ns, dsLinkMAN, cnLinkMAN)

    ' frm.MdiParent = Me

    frm.ShowDialog( )

    Debug.WriteLine (dsLinkMAN.HasC hanges)

    Debug.WriteLine (dsLinkMAN.HasE rrors)

    daLinkMAN_clien t_trans.Update( dsLinkMAN.Table s("client_trans "))

    dsLinkMAN.Table s("client_trans ").Clear()



    In the Child form I have...

    txtpath.DataBin dings.Add(New Binding("Text", ds_client_trans ,
    "client_trans.n man_path"))

    txtdescription. DataBindings.Ad d(New Binding("Text", ds_client_trans ,
    "client_trans.d escription"))

    txtclient.DataB indings.Add(New Binding("Text", ds_client_trans ,
    "client_trans.s ummit_client_id "))

    DataGrid1.DataS ource = ds_client_trans .Tables("client _trans")


    If anyone could shed any light on this I'd be most grateful.

    Thanks,
    Graham



  • William Ryan  eMVP

    #2
    Re: HasChanges not being updated?

    It looks like it thinks no changes have occurred b/c it's still editing.
    call .EndCurrentEdit before you call Update and that should do it for you. I
    don't see the code for the BindingContext/BindingManagerB ase but I'm
    guessing it's in there .. if not, you'll probably wwant to add it so you can
    navigate and all. If you are unfamiliar with it, google for
    BindingManagerb ase and/or BindingContext.

    HTH,

    Bill

    --
    W.G. Ryan MVP Windows - Embedded




    "Graham Blandford" <graham.blandfo rd@sympatico.ca > wrote in message
    news:uxstc.5028 2$tb4.1765179@n ews20.bellgloba l.com...[color=blue]
    > Hi all,
    >
    > I'm sure I must be missing something here.. I've created a simple[/color]
    parent -[color=blue]
    > child form appl. in which I open a dataset in the parent (MDI) using a
    > dataadaptor to an Access database, and a dataset.
    >
    > The SELECT of the record set searches for a specific entry, if it returns[/color]
    a[color=blue]
    > 0 rowcount, I go throiugh the motions of adding a row, and opening the[/color]
    child[color=blue]
    > form.. if it is found I just open the child form..
    >
    > I am passing the dataset through the constuctor to my child form, and if I
    > use a datagrid to change the data, it marks the HasChanges correctly.
    > But, as i am only dealing with one row here, and I would like to use text
    > boxes for each column, I have tried to bind these in code - taken from the
    > .NET library...DataB indings entry...
    >
    > The problem is, if I change the data in a text box, (incidentally, if I
    > leave the datagrid on the form, the cell appears to update for the changed
    > text), the HasChanges flag is not being set to True. Is there something I
    > need to code that will cause this to happen?
    >
    > Here's a snippet of the code...
    >
    > Parent form:
    >
    > With daLinkMAN_clien t_trans
    >
    > .SelectCommand. Parameters("nma n_path").Value = str_nman_path
    >
    > .Fill(dsLinkMAN )
    >
    > End With
    >
    > ' if empty then add
    >
    > If dsLinkMAN.Table s("client_trans ").Rows.Cou nt = 0 Then
    >
    > Dim dr_client_trans As DataRow
    >
    > dr_client_trans = dsLinkMAN.Table s("client_trans ").NewRow
    >
    > With dr_client_trans
    >
    > .Item("nman_pat h") = str_nman_path
    >
    > .Item("descript ion") = "New database"
    >
    > .Item("summit_c lient_id") = ""
    >
    > dsLinkMAN.Table s("client_trans ").Rows.Add(dr_ client_trans)
    >
    > End With
    >
    > End If
    >
    > ' open client form
    >
    > Dim frm As New frmClient(daLin kMAN_client_tra ns, dsLinkMAN, cnLinkMAN)
    >
    > ' frm.MdiParent = Me
    >
    > frm.ShowDialog( )
    >
    > Debug.WriteLine (dsLinkMAN.HasC hanges)
    >
    > Debug.WriteLine (dsLinkMAN.HasE rrors)
    >
    > daLinkMAN_clien t_trans.Update( dsLinkMAN.Table s("client_trans "))
    >
    > dsLinkMAN.Table s("client_trans ").Clear()
    >
    >
    >
    > In the Child form I have...
    >
    > txtpath.DataBin dings.Add(New Binding("Text", ds_client_trans ,
    > "client_trans.n man_path"))
    >
    > txtdescription. DataBindings.Ad d(New Binding("Text", ds_client_trans ,
    > "client_trans.d escription"))
    >
    > txtclient.DataB indings.Add(New Binding("Text", ds_client_trans ,
    > "client_trans.s ummit_client_id "))
    >
    > DataGrid1.DataS ource = ds_client_trans .Tables("client _trans")
    >
    >
    > If anyone could shed any light on this I'd be most grateful.
    >
    > Thanks,
    > Graham
    >
    >
    >[/color]


    Comment

    • Graham  Blandford

      #3
      Re: HasChanges not being updated?

      Thanks Bill,

      I finally have it working - and yes - had to use the BMB ... wasn;t readily
      apparent I had to do this.... most of the doc. examples used the datagrid so
      no mention of it...

      Graham



      "William Ryan eMVP" <dotnetguru@com cast.nospam.net > wrote in message
      news:OSiNxdHREH A.1048@tk2msftn gp13.phx.gbl...[color=blue]
      > It looks like it thinks no changes have occurred b/c it's still editing.
      > call .EndCurrentEdit before you call Update and that should do it for you.[/color]
      I[color=blue]
      > don't see the code for the BindingContext/BindingManagerB ase but I'm
      > guessing it's in there .. if not, you'll probably wwant to add it so you[/color]
      can[color=blue]
      > navigate and all. If you are unfamiliar with it, google for
      > BindingManagerb ase and/or BindingContext.
      >
      > HTH,
      >
      > Bill
      >
      > --
      > W.G. Ryan MVP Windows - Embedded
      >
      > http://forums.devbuzz.com
      > http://www.knowdotnet.com/dataaccess.html
      > http://www.msmvps.com/williamryan/
      > "Graham Blandford" <graham.blandfo rd@sympatico.ca > wrote in message
      > news:uxstc.5028 2$tb4.1765179@n ews20.bellgloba l.com...[color=green]
      > > Hi all,
      > >
      > > I'm sure I must be missing something here.. I've created a simple[/color]
      > parent -[color=green]
      > > child form appl. in which I open a dataset in the parent (MDI) using a
      > > dataadaptor to an Access database, and a dataset.
      > >
      > > The SELECT of the record set searches for a specific entry, if it[/color][/color]
      returns[color=blue]
      > a[color=green]
      > > 0 rowcount, I go throiugh the motions of adding a row, and opening the[/color]
      > child[color=green]
      > > form.. if it is found I just open the child form..
      > >
      > > I am passing the dataset through the constuctor to my child form, and if[/color][/color]
      I[color=blue][color=green]
      > > use a datagrid to change the data, it marks the HasChanges correctly.
      > > But, as i am only dealing with one row here, and I would like to use[/color][/color]
      text[color=blue][color=green]
      > > boxes for each column, I have tried to bind these in code - taken from[/color][/color]
      the[color=blue][color=green]
      > > .NET library...DataB indings entry...
      > >
      > > The problem is, if I change the data in a text box, (incidentally, if I
      > > leave the datagrid on the form, the cell appears to update for the[/color][/color]
      changed[color=blue][color=green]
      > > text), the HasChanges flag is not being set to True. Is there something[/color][/color]
      I[color=blue][color=green]
      > > need to code that will cause this to happen?
      > >
      > > Here's a snippet of the code...
      > >
      > > Parent form:
      > >
      > > With daLinkMAN_clien t_trans
      > >
      > > .SelectCommand. Parameters("nma n_path").Value = str_nman_path
      > >
      > > .Fill(dsLinkMAN )
      > >
      > > End With
      > >
      > > ' if empty then add
      > >
      > > If dsLinkMAN.Table s("client_trans ").Rows.Cou nt = 0 Then
      > >
      > > Dim dr_client_trans As DataRow
      > >
      > > dr_client_trans = dsLinkMAN.Table s("client_trans ").NewRow
      > >
      > > With dr_client_trans
      > >
      > > .Item("nman_pat h") = str_nman_path
      > >
      > > .Item("descript ion") = "New database"
      > >
      > > .Item("summit_c lient_id") = ""
      > >
      > > dsLinkMAN.Table s("client_trans ").Rows.Add(dr_ client_trans)
      > >
      > > End With
      > >
      > > End If
      > >
      > > ' open client form
      > >
      > > Dim frm As New frmClient(daLin kMAN_client_tra ns, dsLinkMAN, cnLinkMAN)
      > >
      > > ' frm.MdiParent = Me
      > >
      > > frm.ShowDialog( )
      > >
      > > Debug.WriteLine (dsLinkMAN.HasC hanges)
      > >
      > > Debug.WriteLine (dsLinkMAN.HasE rrors)
      > >
      > > daLinkMAN_clien t_trans.Update( dsLinkMAN.Table s("client_trans "))
      > >
      > > dsLinkMAN.Table s("client_trans ").Clear()
      > >
      > >
      > >
      > > In the Child form I have...
      > >
      > > txtpath.DataBin dings.Add(New Binding("Text", ds_client_trans ,
      > > "client_trans.n man_path"))
      > >
      > > txtdescription. DataBindings.Ad d(New Binding("Text", ds_client_trans ,
      > > "client_trans.d escription"))
      > >
      > > txtclient.DataB indings.Add(New Binding("Text", ds_client_trans ,
      > > "client_trans.s ummit_client_id "))
      > >
      > > DataGrid1.DataS ource = ds_client_trans .Tables("client _trans")
      > >
      > >
      > > If anyone could shed any light on this I'd be most grateful.
      > >
      > > Thanks,
      > > Graham
      > >
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • William Ryan eMVP

        #4
        Re: HasChanges not being updated?

        Yep, that'll get you and it's an easy thing to overlook, I know I sure did.
        Glad you got it working though.

        Cheers,

        Bill

        --

        W.G. Ryan, eMVP





        "Graham Blandford" <graham.blandfo rd@sympatico.ca > wrote in message
        news:sHFtc.5456 9$tb4.2012237@n ews20.bellgloba l.com...[color=blue]
        > Thanks Bill,
        >
        > I finally have it working - and yes - had to use the BMB ... wasn;t[/color]
        readily[color=blue]
        > apparent I had to do this.... most of the doc. examples used the datagrid[/color]
        so[color=blue]
        > no mention of it...
        >
        > Graham
        >
        >
        >
        > "William Ryan eMVP" <dotnetguru@com cast.nospam.net > wrote in message
        > news:OSiNxdHREH A.1048@tk2msftn gp13.phx.gbl...[color=green]
        > > It looks like it thinks no changes have occurred b/c it's still editing.
        > > call .EndCurrentEdit before you call Update and that should do it for[/color][/color]
        you.[color=blue]
        > I[color=green]
        > > don't see the code for the BindingContext/BindingManagerB ase but I'm
        > > guessing it's in there .. if not, you'll probably wwant to add it so you[/color]
        > can[color=green]
        > > navigate and all. If you are unfamiliar with it, google for
        > > BindingManagerb ase and/or BindingContext.
        > >
        > > HTH,
        > >
        > > Bill
        > >
        > > --
        > > W.G. Ryan MVP Windows - Embedded
        > >
        > > http://forums.devbuzz.com
        > > http://www.knowdotnet.com/dataaccess.html
        > > http://www.msmvps.com/williamryan/
        > > "Graham Blandford" <graham.blandfo rd@sympatico.ca > wrote in message
        > > news:uxstc.5028 2$tb4.1765179@n ews20.bellgloba l.com...[color=darkred]
        > > > Hi all,
        > > >
        > > > I'm sure I must be missing something here.. I've created a simple[/color]
        > > parent -[color=darkred]
        > > > child form appl. in which I open a dataset in the parent (MDI) using a
        > > > dataadaptor to an Access database, and a dataset.
        > > >
        > > > The SELECT of the record set searches for a specific entry, if it[/color][/color]
        > returns[color=green]
        > > a[color=darkred]
        > > > 0 rowcount, I go throiugh the motions of adding a row, and opening the[/color]
        > > child[color=darkred]
        > > > form.. if it is found I just open the child form..
        > > >
        > > > I am passing the dataset through the constuctor to my child form, and[/color][/color][/color]
        if[color=blue]
        > I[color=green][color=darkred]
        > > > use a datagrid to change the data, it marks the HasChanges correctly.
        > > > But, as i am only dealing with one row here, and I would like to use[/color][/color]
        > text[color=green][color=darkred]
        > > > boxes for each column, I have tried to bind these in code - taken from[/color][/color]
        > the[color=green][color=darkred]
        > > > .NET library...DataB indings entry...
        > > >
        > > > The problem is, if I change the data in a text box, (incidentally, if[/color][/color][/color]
        I[color=blue][color=green][color=darkred]
        > > > leave the datagrid on the form, the cell appears to update for the[/color][/color]
        > changed[color=green][color=darkred]
        > > > text), the HasChanges flag is not being set to True. Is there[/color][/color][/color]
        something[color=blue]
        > I[color=green][color=darkred]
        > > > need to code that will cause this to happen?
        > > >
        > > > Here's a snippet of the code...
        > > >
        > > > Parent form:
        > > >
        > > > With daLinkMAN_clien t_trans
        > > >
        > > > .SelectCommand. Parameters("nma n_path").Value = str_nman_path
        > > >
        > > > .Fill(dsLinkMAN )
        > > >
        > > > End With
        > > >
        > > > ' if empty then add
        > > >
        > > > If dsLinkMAN.Table s("client_trans ").Rows.Cou nt = 0 Then
        > > >
        > > > Dim dr_client_trans As DataRow
        > > >
        > > > dr_client_trans = dsLinkMAN.Table s("client_trans ").NewRow
        > > >
        > > > With dr_client_trans
        > > >
        > > > .Item("nman_pat h") = str_nman_path
        > > >
        > > > .Item("descript ion") = "New database"
        > > >
        > > > .Item("summit_c lient_id") = ""
        > > >
        > > > dsLinkMAN.Table s("client_trans ").Rows.Add(dr_ client_trans)
        > > >
        > > > End With
        > > >
        > > > End If
        > > >
        > > > ' open client form
        > > >
        > > > Dim frm As New frmClient(daLin kMAN_client_tra ns, dsLinkMAN, cnLinkMAN)
        > > >
        > > > ' frm.MdiParent = Me
        > > >
        > > > frm.ShowDialog( )
        > > >
        > > > Debug.WriteLine (dsLinkMAN.HasC hanges)
        > > >
        > > > Debug.WriteLine (dsLinkMAN.HasE rrors)
        > > >
        > > > daLinkMAN_clien t_trans.Update( dsLinkMAN.Table s("client_trans "))
        > > >
        > > > dsLinkMAN.Table s("client_trans ").Clear()
        > > >
        > > >
        > > >
        > > > In the Child form I have...
        > > >
        > > > txtpath.DataBin dings.Add(New Binding("Text", ds_client_trans ,
        > > > "client_trans.n man_path"))
        > > >
        > > > txtdescription. DataBindings.Ad d(New Binding("Text", ds_client_trans ,
        > > > "client_trans.d escription"))
        > > >
        > > > txtclient.DataB indings.Add(New Binding("Text", ds_client_trans ,
        > > > "client_trans.s ummit_client_id "))
        > > >
        > > > DataGrid1.DataS ource = ds_client_trans .Tables("client _trans")
        > > >
        > > >
        > > > If anyone could shed any light on this I'd be most grateful.
        > > >
        > > > Thanks,
        > > > Graham
        > > >
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        Working...