Bound controls do not copy across data to underlying data row

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

    Bound controls do not copy across data to underlying data row

    Hi

    I have a small app with bound controls that do not seem to be copying across
    the data entered into them to the underlying row for the update. This one
    really has me stump even though these are very simple steps and I can't see
    where I am going wrong. Any help would be appreciated.

    The relevant code goes as follows;

    Binding controls

    Dim db As System.Windows. Forms.Binding
    ds = MyDataset
    db = New System.Windows. Forms.Binding(" Text", ds.Clients, "ID")
    txtID.DataBindi ngs.Add(db)
    db = New System.Windows. Forms.Binding(" Text", ds.Clients, "Company")
    txtCompany.Data Bindings.Add(db )
    db = New System.Windows. Forms.Binding(" Text", ds.Clients, "Address")
    txtAddress.Data Bindings.Add(db )

    bmCompanyDetail s = CType(BindingCo ntext(ds, "Clients"), CurrencyManager )

    Adding a new record;

    ds.Clients.Clea r()
    bmCompanyDetail s.AddNew()

    Some data is entered in the Company and Address bound fields by user and
    Save button is pressed to save as below;

    Focus()
    bmCompanyDetail s.EndCurrentEdi t()
    Row = DirectCast(bmCo mpanyDetails.Cu rrent, DataRowView).Ro w

    If (Row.RowState = DataRowState.Ad ded) Then
    ' Row.Item(5) = "Test column 5" ' if this line is un-remmed this data is
    stored in datatable so update is working
    daCompanies.Upd ate(ds.Clients)
    End If

    The Clients table is an MS Access table with ID set to Random Auto number.

    Thanks

    Regards


  • W.G. Ryan

    #2
    Re: Bound controls do not copy across data to underlying data row

    So if I understand correctly, the data will update in the underlying row if
    you uncomment that line of code out. If you use yourDataSet.Has Changes(),
    what does it return (putting it right before the Update call?). Is it that
    when you call Update, it doesn't get sent to the DB?

    --
    bill.ryan | technology.evan gelist | magenic.technol ogies
    mvp - device application development


    "John" <John@nospam.in fovis.co.ukwrot e in message
    news:OeXiIK$aIH A.5976@TK2MSFTN GP05.phx.gbl...
    Hi
    >
    I have a small app with bound controls that do not seem to be copying
    across the data entered into them to the underlying row for the update.
    This one really has me stump even though these are very simple steps and I
    can't see where I am going wrong. Any help would be appreciated.
    >
    The relevant code goes as follows;
    >
    Binding controls
    >
    Dim db As System.Windows. Forms.Binding
    ds = MyDataset
    db = New System.Windows. Forms.Binding(" Text", ds.Clients, "ID")
    txtID.DataBindi ngs.Add(db)
    db = New System.Windows. Forms.Binding(" Text", ds.Clients, "Company")
    txtCompany.Data Bindings.Add(db )
    db = New System.Windows. Forms.Binding(" Text", ds.Clients, "Address")
    txtAddress.Data Bindings.Add(db )
    >
    bmCompanyDetail s = CType(BindingCo ntext(ds, "Clients"), CurrencyManager )
    >
    Adding a new record;
    >
    ds.Clients.Clea r()
    bmCompanyDetail s.AddNew()
    >
    Some data is entered in the Company and Address bound fields by user and
    Save button is pressed to save as below;
    >
    Focus()
    bmCompanyDetail s.EndCurrentEdi t()
    Row = DirectCast(bmCo mpanyDetails.Cu rrent, DataRowView).Ro w
    >
    If (Row.RowState = DataRowState.Ad ded) Then
    ' Row.Item(5) = "Test column 5" ' if this line is un-remmed this data is
    stored in datatable so update is working
    daCompanies.Upd ate(ds.Clients)
    End If
    >
    The Clients table is an MS Access table with ID set to Random Auto number.
    >
    Thanks
    >
    Regards
    >

    Comment

    • John

      #3
      Re: Bound controls do not copy across data to underlying data row

      Ryan, it was a binding issue which Miha has kindly solved for me in another
      thread.

      Many Thanks

      Regards

      "W.G. Ryan" <WilliamRyan@no spam.gmail.comw rote in message
      news:OpUcoGLbIH A.5208@TK2MSFTN GP04.phx.gbl...
      So if I understand correctly, the data will update in the underlying row
      if you uncomment that line of code out. If you use
      yourDataSet.Has Changes(), what does it return (putting it right before the
      Update call?). Is it that when you call Update, it doesn't get sent to
      the DB?
      >
      --
      bill.ryan | technology.evan gelist | magenic.technol ogies
      mvp - device application development


      "John" <John@nospam.in fovis.co.ukwrot e in message
      news:OeXiIK$aIH A.5976@TK2MSFTN GP05.phx.gbl...
      >Hi
      >>
      >I have a small app with bound controls that do not seem to be copying
      >across the data entered into them to the underlying row for the update.
      >This one really has me stump even though these are very simple steps and
      >I can't see where I am going wrong. Any help would be appreciated.
      >>
      >The relevant code goes as follows;
      >>
      >Binding controls
      >>
      >Dim db As System.Windows. Forms.Binding
      >ds = MyDataset
      >db = New System.Windows. Forms.Binding(" Text", ds.Clients, "ID")
      >txtID.DataBind ings.Add(db)
      >db = New System.Windows. Forms.Binding(" Text", ds.Clients, "Company")
      >txtCompany.Dat aBindings.Add(d b)
      >db = New System.Windows. Forms.Binding(" Text", ds.Clients, "Address")
      >txtAddress.Dat aBindings.Add(d b)
      >>
      >bmCompanyDetai ls = CType(BindingCo ntext(ds, "Clients"), CurrencyManager )
      >>
      >Adding a new record;
      >>
      >ds.Clients.Cle ar()
      >bmCompanyDetai ls.AddNew()
      >>
      >Some data is entered in the Company and Address bound fields by user and
      >Save button is pressed to save as below;
      >>
      >Focus()
      >bmCompanyDetai ls.EndCurrentEd it()
      >Row = DirectCast(bmCo mpanyDetails.Cu rrent, DataRowView).Ro w
      >>
      >If (Row.RowState = DataRowState.Ad ded) Then
      > ' Row.Item(5) = "Test column 5" ' if this line is un-remmed this data
      >is stored in datatable so update is working
      > daCompanies.Upd ate(ds.Clients)
      >End If
      >>
      >The Clients table is an MS Access table with ID set to Random Auto
      >number.
      >>
      >Thanks
      >>
      >Regards
      >>
      >
      >

      Comment

      Working...