Esempio n. 1
0
        public city cityXml(int zipCode)
        {
            var sehir = new city();



            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["mytest"].ConnectionString);

            conn.Open();
            string     sqlCity = "select * from tblCity where zipCode=" + zipCode.ToString();
            SqlCommand cmd     = new SqlCommand(sqlCity, conn);


            SqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                sehir.id       = Int32.Parse(dr["Id"].ToString());
                sehir.zipCode  = dr["zipCode"].ToString();
                sehir.cityName = dr["cityname"].ToString();
            }

            dr.Close();
            conn.Close();
            return(sehir);
        }
Esempio n. 2
0
        public ArrayList cityListXml()
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["mytest"].ConnectionString);

            conn.Open();
            string        sqlCity  = "select * from tblCity";
            SqlCommand    cmd      = new SqlCommand(sqlCity, conn);
            SqlDataReader dr       = cmd.ExecuteReader();
            ArrayList     sehirler = new ArrayList();

            while (dr.Read())
            {
                var sehir = new city();

                sehir.id       = Int32.Parse(dr["Id"].ToString());
                sehir.zipCode  = dr["zipCode"].ToString();
                sehir.cityName = dr["cityname"].ToString();
                sehir.bolge    = dr["bolge"].ToString();

                sehirler.Add(sehir);
            }
            dr.Close();
            conn.Close();
            return(sehirler);
        }