| | |
can not update combo box...
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2006
Posts: 22
Reputation:
Solved Threads: 0
Hi,
I have written a program that binds controls on a form to fields of a table in a Microsoft Access database.One of the controls on the form is a combo box that is binding to table called Type_T which contains one column called Type.
i need to update the combo box whith the new values when i update the table Type_T. the addition of the table going fine and i see the record updated, but the combo box remain without changes.
I have tried this code :
but nothing happened.
I have tried this also:
there were no changes in the combo box.
in addition, this was my last attempt to update it which is to call ReFillCombo()
and it gives me this error: Items collection can not be modified when the datasource property is set.
every time i have to close the application and re run it again to see the updat in the combo box.
please help me !!
I have written a program that binds controls on a form to fields of a table in a Microsoft Access database.One of the controls on the form is a combo box that is binding to table called Type_T which contains one column called Type.
i need to update the combo box whith the new values when i update the table Type_T. the addition of the table going fine and i see the record updated, but the combo box remain without changes.
I have tried this code :
VB.NET Syntax (Toggle Plain Text)
Me.ComboBox2.DataSource = Nothing Me.ComboBox2.DataSource = Me.DataBaseDataSet.Type_T 'Me.ComboBox2.DataSource = Me.TypeTBindingSource Me.ComboBox2.DisplayMember = "Type" Me.ComboBox2.ValueMember = "Type"
but nothing happened.
I have tried this also:
VB.NET Syntax (Toggle Plain Text)
Dim bd As Binding bd = New Binding("Text", ds, "Type_T.Type") Me.ComboBox2.DataBindings.Add(bd)
in addition, this was my last attempt to update it which is to call ReFillCombo()
VB.NET Syntax (Toggle Plain Text)
Private Sub ReFillCombo() Me.ComboBox2.Items.Clear() ' Clear the items of the combobox Dim constr As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Documents and Settings\HST\My Documents\Visual Studio 2005\Projects\Invoice\Invoice\DataBase.mdb" Dim conn As New OleDb.OleDbConnection(constr) Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM Type_T", conn) Dim dt As New DataTable da.Fill(dt) Me.ComboBox1.DataSource = dt Me.ComboBox1.DisplayMember = "Type" Me.ComboBox1.ValueMember = "Type" End Sub
and it gives me this error: Items collection can not be modified when the datasource property is set.
every time i have to close the application and re run it again to see the updat in the combo box.
please help me !!
•
•
Join Date: Mar 2006
Posts: 22
Reputation:
Solved Threads: 0
Private Sub ReFillCombo()
Me.ComboBox2.Items.Clear() ' Clear the items of the combobox
Dim constr As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Documents and Settings\HST\My Documents\Visual Studio 2005\Projects\Invoice\Invoice\DataBase.mdb"
Dim conn As New OleDb.OleDbConnection(constr)
Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM Type_T", conn)
Dim dt As New DataTable
da.Fill(dt)
Me.ComboBox1.DataSource = ds.Tables("Temp_table")
Me.ComboBox1.DisplayMember = "Type"
Me.ComboBox1.ValueMember = "Type"
End Sub
Me.ComboBox2.Items.Clear() ' Clear the items of the combobox
Dim constr As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Documents and Settings\HST\My Documents\Visual Studio 2005\Projects\Invoice\Invoice\DataBase.mdb"
Dim conn As New OleDb.OleDbConnection(constr)
Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM Type_T", conn)
Dim dt As New DataTable
da.Fill(dt)
Me.ComboBox1.DataSource = ds.Tables("Temp_table")
Me.ComboBox1.DisplayMember = "Type"
Me.ComboBox1.ValueMember = "Type"
End Sub
![]() |
Similar Threads
- Updating Combo Box (Visual Basic 4 / 5 / 6)
- combo box (PHP)
- Want to use radio button or menu bar instead of combo box (Java)
- combo box (ASP)
- How do I limit text char in Combo box? (VB.NET)
- combo box help (VB.NET)
Other Threads in the VB.NET Forum
- Previous Thread: login
- Next Thread: [urgent] Need Help on my VB6 game
Views: 5440 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2008 2008 access add advanced application array assignment basic beginner box browser button buttons center click client code combo convert cpu cuesent data database datagrid datagridview datetimepicker designer dissertation dissertations dissertationtopic eclipse editvb.net employees excel exists forms function html images isnumericfuntioncall lib listview map mobile module msaccess mssqlbackend mysql net number open page pan pdf picturebox picturebox2 port print printing printpreview problem record regex reuse richtextbox right-to-left save search serial settings socket sorting sqldatbase sqlserver storedprocedure structures temp textbox timer transparency txttoxmlconverter usercontol vb vb.net vb2008 vba vbnet vista visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web winsock wpf wrapingcode xml






... it was in this code: