none
Linked TableAdapter for ComboBox vs. accessing Access database as BindingSource

    Question

  • I'm having a problem setting up my Access Database in my application.

    I need to be able to do 2 distinct things:
    1) Use tables in the database (or queries) to populate controls such as ComboBoxes
    2) Read and update tables in the database directly from Code not from linked TextBoxes on a form.

    I want my database to be in <application directory>/App_Data (which is where I placed it).

    For some reason, when the app runs and I have a:
    <tblName>TableAdapter.Fill(me.<>DataSet.<tablename>)
    command, it is looking in <application directory>/bin/Debug/App_Data which does not exist.

    How do I get it to not look in "/bin/Debug/" ?

    I'm just looking for this answer now. #1

    Thanks,

    Paul Goldstein


    Paul D. Goldstein Forceware Systems, Inc.

    Friday, January 18, 2013 1:49 AM

All replies

  • Try so split your question, this forum is also a knowledge base. 

    But like you say, this for #1

    There are many samples for that on our website use this one.

    http://www.vb-tips.com/AdoNetDataAdapterDesignerAndUpdate.ASPX

    Use this one with the combobox

    http://www.vb-tips.com/WindowsFormsComboboxWithDataAdapter.ASPX


    Success
    Cor

    Friday, January 18, 2013 1:04 PM
  • Hi Cor,

    Okay. I got the WindowsFormsCombobox example to work in my form.

    Here's why I asked it as a 2 part question, if you want I will repost.

    I have another form, that reads another table and builds a TreeView.
    I use a BindingSource to read the Table and populate the TreeView.

    The building of the TreeView is working fine. The user than has the option of updating a field in the Table, based on changes in the TreeView. The TreeView contains information about recordings that will end up on a CD, so the TreeView is used to drag items in the TreeView to change the Order of the tracks on the CD, and also uses an Image to indicate if the item is to be left off of the CD.

    The table contains the field IncludeOnCD, and this is the field that I am testing the update for now.

    I'm not using a MoveFirst, MoveNext logic, because under testing I can't determine when I'm past EOF, it always returns the Count value as the Position value, but it also does that when you read the final record, if you execute MoveNext after this, it doesn't return an error, so I can't determine if I'm at EOF. So instead I do this:

    For IX = 0 to Me.TreeView1.Count
      ixCDOrder = bsCDOrder.Find("RecordingType", Me.TreeView1.Nodes(IX).Text.ToString)
      bsCDOrder.Position = ixCDOrder
      Select Case Me.TreeView1.Nodes(IX).SelectedImage
        Case "CDYes": bsCDOrder.Current("IncludeOnCD") = True
        Case "CDNo": bsCDOrder.Current("IncludeOnCD") = False
      End Select
      Debug.Print(bsCDOrder.Current("IncludeOnCD").ToString()) ' This is displaying the correct value in my testing
      Call subSaveCDOrder
    Next

    Sub subSaveCDOrder
      bsCDOrder.EndEdit()
      Dim cmd As New OleDbCommandBuilder(daCDOrder)
      daCDOrder.Update(dtCDOrder)
      dtCDOrder.AcceptChanges()
    end Sub

    When I open the form again and build the TreeView, the fields are not updated.

    Any ideas?

    Thanks,

    Paul 


    Paul D. Goldstein Forceware Systems, Inc.

    Friday, January 18, 2013 8:17 PM