0

I wanted to know as to how can i filter records based in a database to place them in a combo-box. For example i have a sql statement that says: "select stock_items from stock_master where ID=XYZ" and based on this command, I want all those values to be be shown in ComboBox1

Thanks

ilyas
  • 135
  • 10

1 Answers1

2

1)Using SqlCommand use your command:-(select stock_items from stock_master where ID=XYZ) like SqlCommand *com*=new SqlCommand(select stock_items from stock_master where
ID=XYZ,connection);

2)using SqlDataReader Read The Data From The Database like SqlDataReader dr= com.ExecuteReader();

3)using SqlDataReader Object Read The Particular Items..here like Stock_items . Read Data from the SqldataReader like this. E.G:- ComboBox1.Items.Add(dr.Tables[0].Rows[0]["Stock_item"].toString());

THNXX..:)

pRaNaY
  • 24,642
  • 24
  • 96
  • 146