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 that is called "Beer" and has several names, I would like to list that column in a ComboBox. Thanks.
I have a Stored Procedure:
CREATE PROCEDURE [dbo].[LoadCerveja]
(
@Cerveja varchar(60)
)
AS
SELECT @cerveja from Ingredientes
RETURN
In the code I need to add in the formLoad for it to pull the ComboBox to the "Beer" column of the database.
I tried the following (no 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.");
}