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;
}
}
}
}
此代码填充列表框,当我尝试从选定索引中获取值时,我似乎无法找到获取索引值的方法。