私はVb.netで新しく、私はこのコードを使用します。MysqlデータベースからComboboxをロードするには。 うまく動作しますが、ゆっくりですvb.net Comboboxをもっと速くロードする方法
すべてを実行する方法はありますか?クエリを実行し、すべてのComboboxをロードするか、別の方法でこのタスクを実行しますか?
AbrirDB()
comandomysql.CommandText = "select distinct TblMarcas.marca from TblMarcas order by marca"
Try
Lector = comandomysql.ExecuteReader
Lector.Read()
.cbom.Properties.Items.Clear()
If Lector.HasRows Then
.cbom.Properties.Items.Add(Lector.Item("marca"))
Do While Lector.Read
.cbom.Properties.Items.Add(Lector.Item("marca"))
Loop
Else
End If
Catch ex As Exception
DevExpress.XtraEditors.XtraMessageBox.Show(Err.Number & Err.Description)
If conexion.State = ConnectionState.Open Then conexion.Close()
End Try
CerrarDb()
'CARGO Categorias a treelist
AbrirDB()
comandomysql.CommandText = "select distinct TblCategorias.categoria from TblCategorias order by categoria ASC"
Try
Lector = comandomysql.ExecuteReader
Lector.Read()
.cboc.Properties.Items.Clear()
If Lector.HasRows Then
.cboc.Properties.Items.Add(Lector.Item("categoria"))
Do While Lector.Read
.cbocategoria.Properties.Items.Add(Lector.Item("categoria"))
Loop
Else
End If
Catch ex As Exception
DevExpress.XtraEditors.XtraMessageBox.Show(Err.Number & Err.Description)
If conexion.State = ConnectionState.Open Then conexion.Close()
End Try
CerrarDb()
'CARGO Subcategorias
AbrirDB()
comandomysql.CommandText = "select distinct TblSubcategorias.subcategoria from TblSubcategorias order by subcategoria ASC"
Try
Lector = comandomysql.ExecuteReader
Lector.Read()
.cbos.Properties.Items.Clear()
If Lector.HasRows Then
.cbos.Properties.Items.Add(Lector.Item("subcategoria"))
Do While Lector.Read
.cbos.Properties.Items.Add(Lector.Item("subcategoria"))
Loop
End If
Catch ex As Exception
DevExpress.XtraEditors.XtraMessageBox.Show(Err.Number & Err.Description)
If conexion.State = ConnectionState.Open Then conexion.Close()
End Try
CerrarDb()
助けてください。
DataTableを入力してCBO.DataSourceをバインドします。例:http://stackoverflow.com/a/36142887/1070452 – Plutonix