/// <summary> /// get an instance of object /// </summary> /// <param name="myID"></param> public p_paradero getObjectp_paradero(System.Int32 myID) { p_paradero myp_paradero = new p_paradero(); CnxBase myBase = new CnxBase(); string reqSQL = "SELECT gid,id,avenida,sgc1,sgc2,the_geom FROM p_paradero WHERE (gid=" + myID + ")"; try { NpgsqlConnection myConn = myBase.OpenConnection(myBase.cnxString); NpgsqlCommand myCommand = new NpgsqlCommand(reqSQL, myConn); NpgsqlDataReader myReader = myCommand.ExecuteReader(); if (myReader.Read()) { myp_paradero.gid = Convert.ToInt32(myReader[0]); myp_paradero.id = Convert.ToInt32(myReader[1]); myp_paradero.avenida = myReader[2].ToString(); myp_paradero.sgc1 = Convert.ToInt64(myReader[3]); myp_paradero.sgc2 = myReader[4].ToString(); myp_paradero.the_geom = myReader[5].ToString(); } myBase.CloseConnection(myConn); } catch (Exception myErr) { throw(new Exception(myErr.ToString() + reqSQL)); } return(myp_paradero); }
/// <summary> /// modify a record /// </summary> public void Update(p_paradero myp_paradero) { CnxBase myBase = new CnxBase(); string reqSQL = "UPDATE p_paradero SET gid=" + myp_paradero.gid + ",id=" + myp_paradero.id + ",avenida='" + myp_paradero.avenida + "',sgc1=" + myp_paradero.sgc1 + ",sgc2='" + myp_paradero.sgc2 + "',the_geom='" + myp_paradero.the_geom + "' WHERE (gid=" + myp_paradero.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)); } }
/// <summary> /// add a record /// </summary> /// <param name="myID"></param> public void Insert(p_paradero myp_paradero) { CnxBase myBase = new CnxBase(); string reqSQL = "INSERT INTO p_paradero (gid,id,avenida,sgc1,sgc2,the_geom) VALUES (" + myp_paradero.gid + "," + myp_paradero.id + ",'" + myp_paradero.avenida + "'," + myp_paradero.sgc1 + ",'" + myp_paradero.sgc2 + "','" + myp_paradero.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)); } }