I am working in Visual studio 2003. I try to bind the combobox with a table from Microsoft Acess. I sucess to bind the GridData but fail in combobox. The combobox List not showing the correct data but show the word "System.Data.DataRowView" . Can someone help me abt this matter? thank
The codes is as below:
Dim myconnection As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=..\EdenSelect.mdb;")
Dim mydataadpater AsNew OleDbDataAdapter
Dim mydataset As DataSet = New DataSet
mydataadpater.SelectCommand = New OleDbCommand
mydataadpater.SelectCommand.Connection = myconnection
mydataadpater.SelectCommand.CommandText = "SELECT Field1 FROM Product WHERE CategoriesP='2'"
myconnection.Open()
mydataadpater.Fill(mydataset, "Product")
myconnection.Close()
grdData.DataSource = mydataset
grdData.DataMember = "Product"
ComboBox1.DataBindings.Add("SelectedItem", mydataset, "Product")
ComboBox1.DataBindings.Add("DataSource", mydataset, "Product")
ComboBox1.DataSource = mydataset
ComboBox1.DisplayMember = "Field1"
The codes is as below:
Dim myconnection As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=..\EdenSelect.mdb;")
Dim mydataadpater AsNew OleDbDataAdapter
Dim mydataset As DataSet = New DataSet
mydataadpater.SelectCommand = New OleDbCommand
mydataadpater.SelectCommand.Connection = myconnection
mydataadpater.SelectCommand.CommandText = "SELECT Field1 FROM Product WHERE CategoriesP='2'"
myconnection.Open()
mydataadpater.Fill(mydataset, "Product")
myconnection.Close()
grdData.DataSource = mydataset
grdData.DataMember = "Product"
ComboBox1.DataBindings.Add("SelectedItem", mydataset, "Product")
ComboBox1.DataBindings.Add("DataSource", mydataset, "Product")
ComboBox1.DataSource = mydataset
ComboBox1.DisplayMember = "Field1"