0
I would like to know how to load values in a combobox, listing an entire column of the database, for example, I have a column called "Beer" and it has several names, I would like to list this column in a Combobox. Thanks.
I have a stored procedure:
CREATE PROCEDURE [dbo].[LoadCerveja]
(
@Cerveja varchar(60)
)
AS
SELECT @cerveja from Ingredientes
RETURN
and in the code I need to add to the formLoad for him to pull the "Beer" column from the database.
I tried to do the following (in the form load)
private void Form1_Load(object sender, EventArgs e)
{
try
{
conexao.Open();
SqlCommand cmdd = new SqlCommand("LoadIngredients", conexao);
cmdd.CommandType = CommandType.StoredProcedure;
cmdd.Parameters.Add("@Cerveja");
SqlDataReader DR;
DR = cmdd.ExecuteReader();
{
comboBox1.Items.Add(DR.GetValue()); **// Não sei o que fazer aqui pra adicionar os dados ao combobox !!!!**
}
else MessageBox.Show("Erro ao buscar receita no DB.");
}
Could you add more information to the question? It will look better to help you if you have more information. Have some code where you try to load the information in the combobox?
– gato
I’ve edited here, thanks
– tutiBits