1
I have a product registration screen with a LOCAL Combobox. Product table has the LOCAL ID, called pro_local. And the local table the fields loc_cod and loc_descricao
My combobox is filled with the function:
public DataTable RetornaLocal()
{
SqlConnection sqlConnection = acessoDadosSqlServer.CriarConexao();
sqlConnection.Open();
SqlCommand sqlCommand = sqlConnection.CreateCommand();
sqlCommand.CommandText = "SELECT * FROM local ORDER BY loc_descricao";
SqlDataReader sqlDataReader = null;
sqlDataReader = sqlCommand.ExecuteReader();
DataTable dataTable = new DataTable();
dataTable.Load(sqlDataReader);
return dataTable;
}
In the product form:
cbLocal.DisplayMember = "loc_descricao";
cbLocal.ValueMember = "loc_cod";
cbLocal.DataSource = localNegocios.RetornaLocal();
These functions fill the combobox, but when I bring the product form to change this product, it brings the combobox as if it were an insert, it does not bring selected the pro_local saved in the bank. How to fill a combobox with a certain ID at the top?
Att.