Beispiel #1
0
        public Projekt GetProjekt(int proj_id)
        {
            Projekt         p    = new Projekt();
            MySqlConnection conn = new MySqlConnection("server=localhost;uid=root;");

            conn.Open();
            conn.ChangeDatabase("projekte");
            MySqlCommand    comm   = new MySqlCommand("select pj_id,pj_name from projekt where pj_id = " + proj_id, conn);
            MySqlDataReader Reader = comm.ExecuteReader();

            Reader.Read();
            p.Id   = (int)Reader["pj_id"];
            p.Name = Reader["pj_name"].ToString();
            Reader.Close();
            conn.Close();
            return(p);
        }
Beispiel #2
0
        public Projekt[] AlleProjekte()
        {
            List <Projekt> projekte = new List <Projekt>();
            //comm.CommandText = "Select pj_id,pj_name from projekt";
            //comm = conn.CreateCommand();
            MySqlConnection conn = new MySqlConnection("server=localhost;uid=root;");

            conn.Open();
            conn.ChangeDatabase("projekte");
            MySqlCommand    comm   = new MySqlCommand("Select pj_id,pj_name from projekt", conn);
            MySqlDataReader Reader = comm.ExecuteReader();

            while (Reader.Read())
            {
                Projekt p = new Projekt();
                p.Id   = (int)Reader["pj_id"];
                p.Name = Reader["pj_name"].ToString();
                projekte.Add(p);
            }
            Reader.Close();
            conn.Close();
            return(projekte.ToArray());
        }