none
silverlight datagridden listboxa veri cekme acil yardım RRS feed

Yanıtlar

  • try
    {
    if (baglan.State == System.Data.ConnectionState.Closed)
    {
       baglan.Open();
       SqlCommand komut = new SqlCommand("SELECT isim FROM ogrenci", baglan);
       SqlDataReader dr;
       dr = komut.ExecuteReader();
       while (dr.Read())
       {
          listBox1.Items.Add((dr["isim"]).ToString());
       }
    }
    baglan.Close();
    }
    catch (Exception ex)
    {
       MessageBox.Show(ex.Message);
    }

    Yukarıdaki SQL için

    Bu ise Access için

                try
                {
                    if (conn.State == System.Data.ConnectionState.Closed)
                    {
                        conn.Open();
                        OleDbCommand komut = new OleDbCommand("SELECT isim FROM ogrenci", conn);
                        OleDbDataReader dr;
                        dr = komut.ExecuteReader();
                        while (dr.Read())
                        {
                            listBox1.Items.Add((dr["isim"]).ToString());
                        }
                    }
                    conn.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }


    26 Mayıs 2013 Pazar 20:49