943,783 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 4515
  • VB.NET RSS
May 31st, 2008
0

Popup Form Refresh combobox on parent form

Expand Post »
I have a parent form that has a combobox. Whn the form loads I get the data from the db and bind to the combobox. that works fine and here is the code I use in form load to cause this to happen:

VB.NET Syntax (Toggle Plain Text)
  1. conn.Open()
  2. cmd.Connection = conn
  3. da = New SqlCeDataAdapter(cmd1, conn)
  4.  
  5. cmd.CommandText = "SELECT * FROM AccountType ORDER BY AcctType"
  6. da2 = New SqlCeDataAdapter(cmd)
  7. da2.Fill(dtAcctType)
  8.  
  9. cmd.CommandText = chkSQL
  10. daCk = New SqlCeDataAdapter(chkSQL, conn)
  11. daCk.Fill(dtChk)
  12.  
  13.  
  14.  
  15. cboType.DataSource = dtAcctType
  16. cboType.DisplayMember = "AcctType"
  17. cboType.ValueMember = "AcctTypeID"
  18. cboType.SelectedIndex = 0

Now if there is not an Account Type, I have a button that will pull up a small form to allow the addition of an account type. The popup form adds the data back to the database just fine, but I am now trying to get the combobox to refresh its data. So I call a public Sub that is located in the parent form to from the popup form to accomplish this task and I have walked the code and the sub is called and appears to work correctly, but the new data never appears in the combobox. Here is my public sub that i call to try and refresh the combobox on the parent form.

VB.NET Syntax (Toggle Plain Text)
  1. Dim dtType As New DataTable
  2. Dim daType As SqlCeDataAdapter
  3.  
  4.  
  5. Try
  6. conn = New SqlCeConnection("Data Source=C:\Program Files\HomeComplete\Data\HomeComplete.sdf")
  7. Catch
  8. End Try
  9.  
  10. Dim cmd As New SqlServerCe.SqlCeCommand
  11.  
  12. cmd.Connection = conn
  13.  
  14. cmd.CommandText = "SELECT * FROM AccountType ORDER BY AcctType"
  15. daType = New SqlCeDataAdapter(cmd)
  16.  
  17. daType.Fill(dtType)
  18. cboType.Items.Clear()
  19. cboType.DataSource = dtType
  20. cboType.DisplayMember = "AcctType"
  21. cboType.ValueMember = "AcctTypeID"
  22. cboType.SelectedIndex = 0
  23. cboType.Refresh()
  24.  
  25.  
  26. conn.Close()

But when I go back to the parent form, the combobox is not updated with the new account. How can i get the combobox to refresh from the database with the new data?

Thank You, Chester
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
cpopham is offline Offline
65 posts
since Mar 2005
May 31st, 2008
0

Re: Popup Form Refresh combobox on parent form

i have used something as easy as in the click event where you add your data on the second form just add
vb.net Syntax (Toggle Plain Text)
  1. frmOther.refresh
Reputation Points: 31
Solved Threads: 29
Posting Whiz in Training
ProfessorPC is offline Offline
270 posts
since Dec 2007
May 31st, 2008
0

Re: Popup Form Refresh combobox on parent form

I tried that and also on the Public sub that is in the parent form I put it there as well, but it is still not working...
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
cpopham is offline Offline
65 posts
since Mar 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Chart?
Next Thread in VB.NET Forum Timeline: Factorial of N





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC