Example #1
0
        /// <summary>
        /// get an instance of object
        /// </summary>
        /// <param name="myID"></param>
        public k_grifos getObjectk_grifos(System.Int32 myID)
        {
            k_grifos myk_grifos = new k_grifos();
            CnxBase  myBase     = new CnxBase();
            string   reqSQL     = "SELECT gid,identifica,comuna_,direccion,the_geom FROM k_grifos WHERE (gid=" + myID + ")";

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                NpgsqlDataReader myReader  = myCommand.ExecuteReader();
                if (myReader.Read())
                {
                    myk_grifos.gid        = Convert.ToInt32(myReader[0]);
                    myk_grifos.identifica = Convert.ToInt32(myReader[1]);
                    myk_grifos.comuna_    = myReader[2].ToString();
                    myk_grifos.direccion  = myReader[3].ToString();
                    myk_grifos.the_geom   = myReader[4].ToString();
                }
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw(new Exception(myErr.ToString() + reqSQL));
            }
            return(myk_grifos);
        }
Example #2
0
        /// <summary>
        /// modify a record
        /// </summary>
        public void Update(k_grifos myk_grifos)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "UPDATE k_grifos SET gid=" + myk_grifos.gid + ",identifica=" + myk_grifos.identifica + ",comuna_='" + myk_grifos.comuna_ + "',direccion='" + myk_grifos.direccion + "',the_geom='" + myk_grifos.the_geom + "' WHERE (gid=" + myk_grifos.gid + ")";

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                myCommand.ExecuteNonQuery();
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw(new Exception(myErr.ToString() + reqSQL));
            }
        }
Example #3
0
        /// <summary>
        /// add a record
        /// </summary>
        /// <param name="myID"></param>
        public void Insert(k_grifos myk_grifos)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "INSERT INTO k_grifos (gid,identifica,comuna_,direccion,the_geom) VALUES (" + myk_grifos.gid + "," + myk_grifos.identifica + ",'" + myk_grifos.comuna_ + "','" + myk_grifos.direccion + "','" + myk_grifos.the_geom + "')";

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                myCommand.ExecuteNonQuery();
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw(new Exception(myErr.ToString() + reqSQL));
            }
        }