string KaloriSorgusu = "use FoodDB select drink_kal from Drinks";
SqlConnection baglanti2 = new SqlConnection("Data Source=" + IPFORM.ip.ToString() + "\\SQLEXPRESS;Initial Catalog=UserDB;User Id=Levent; Password=21012101;Trusted_Connection=False;Integrated Security=False");
using (baglanti2)
{
using (SqlCommand KaloriKomutu = new SqlCommand(KaloriSorgusu, baglanti2))
{
baglanti2.Open();
using (SqlDataReader KALORİokuyucu = KaloriKomutu.ExecuteReader())
{
while (KALORİokuyucu.Read())
{
lb_Kalori.Items.Add(KALORİokuyucu.GetValue(0).ToString());
total = lb_Kalori.Items.Count;
}
}
}
}
This code populates the listbox and when I try to get values from selected index I can't seem to find a way to get the value of an index.