public int viewTroops() { Oracle.ManagedDataAccess.Client.OracleConnection conn = new Oracle.ManagedDataAccess.Client.OracleConnection(DbConnect.oradb); String strSQL = "SELECT * FROM V_PlayerTroops"; conn.Open(); Oracle.ManagedDataAccess.Client.OracleCommand cmd = new Oracle.ManagedDataAccess.Client.OracleCommand(strSQL, conn); Oracle.ManagedDataAccess.Client.OracleDataReader dr = cmd.ExecuteReader(); //read the record in dr dr.Read(); if (dr.IsDBNull(0)) { playerTroops = 1; } else { playerTroops = Convert.ToInt16(dr.GetValue(0)) + 1; } conn.Close(); return(playerTroops); }
public List <Address> getCityStore(Connection connection) { try { if (connection._connection.State == System.Data.ConnectionState.Closed) { connection.Open(); } var command = new OracleCommand("getCities", connection._connection); command.CommandType = System.Data.CommandType.StoredProcedure; List <Address> addressList = new List <Address>(); OracleParameter output = command.Parameters.Add("l_cursor", OracleDbType.RefCursor); output.Direction = System.Data.ParameterDirection.ReturnValue; command.ExecuteNonQuery(); Oracle.ManagedDataAccess.Client.OracleDataReader reader = command.ExecuteReader(); while (reader.Read()) { Address address = new Address( reader.GetInt32(0), reader.GetString(1)); addressList.Add(address); } connection.Close(); return(addressList); // return null; } catch (Exception e) { connection.Close(); throw; } }
public void Chercher_Reprise(string id, out string erreur, out Bon_reprise br, out Boolean exist) { erreur = null; br = new Bon_reprise(); exist = false; rsql = "select * from BON_REPRISE where BON_REPRISE.NUM_BONREPRISE='" + id + "' "; cnx.select(rsql, out erreur, out dr); if (erreur == null) { if (dr.HasRows == true) { exist = true; dr.Read(); br.NUM_BONREPRISES = dr.GetString(0); br.DATE_REPRISE_REELS = dr.GetDateTime(1); br.NUM_TITRECONGES = dr.GetString(2); } dr.Close(); } }
public List <Products_Info> GetDbProductsList(Connection connection, int id) { try { if (connection._connection.State == System.Data.ConnectionState.Closed) { connection.Open(); } var command = new Oracle.ManagedDataAccess.Client.OracleCommand("returnCartPro", connection._connection); command.CommandType = System.Data.CommandType.StoredProcedure; List <Products_Info> products_Info_list = new List <Products_Info>(); command.Parameters.Add("ID_INPUT", OracleDbType.Int32, System.Data.ParameterDirection.Input).Value = id; Oracle.ManagedDataAccess.Client.OracleParameter p_rc = command.Parameters.Add("rc", OracleDbType.RefCursor, DBNull.Value, System.Data.ParameterDirection.Output); // Oracle.ManagedDataAccess.Client.OracleParameter output = command.Parameters.Add("rc", OracleDbType.RefCursor); // output.Direction = System.Data.ParameterDirection.ReturnValue; command.ExecuteNonQuery(); Oracle.ManagedDataAccess.Client.OracleDataReader reader = command.ExecuteReader(); while (reader.Read()) { Products_Info products_Info = new Products_Info( reader.GetInt32(0), reader.GetString(1), reader.GetInt32(2), reader.GetInt32(3), reader.GetString(4), reader.GetString(5)); products_Info_list.Add(products_Info); } connection.Close(); return(products_Info_list); // return null; } catch (Exception e) { connection.Close(); throw; } }
private void previousOrdersBtn_Click(object sender, EventArgs e) { string[] words = greetingLabel.Text.Split(' '); string name = words[1]; string surname = words[2]; Connection connection = new Connection(); if (connection._connection.State == System.Data.ConnectionState.Closed) { connection.Open(); } var command = new Oracle.ManagedDataAccess.Client.OracleCommand("GETUSERORDERS1", connection._connection); command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.Add("nume", OracleDbType.Varchar2, System.Data.ParameterDirection.Input).Value = name; command.Parameters.Add("prenume", OracleDbType.Varchar2, System.Data.ParameterDirection.Input).Value = surname; List <Order> orders_list = new List <Order>(); Oracle.ManagedDataAccess.Client.OracleParameter output = command.Parameters.Add("l_cursor", OracleDbType.RefCursor); output.Direction = System.Data.ParameterDirection.ReturnValue; command.ExecuteNonQuery(); Oracle.ManagedDataAccess.Client.OracleDataReader reader = command.ExecuteReader(); while (reader.Read()) { Order order = new Order(reader.GetInt32(0)); orders_list.Add(order); } connection.Close(); seeOrdersForm seeOrdersForm = new seeOrdersForm(connection, orders_list); }
public ActionResult Lister() { User user = (User)Session["User"]; Oracle.ManagedDataAccess.Client.OracleCommand ObjSelct = new Oracle.ManagedDataAccess.Client.OracleCommand("select * from QUESTIONS", user.connexion); Oracle.ManagedDataAccess.Client.OracleDataReader ObjeRead = ObjSelct.ExecuteReader(); List <Question> q = new List <Question>(); while (ObjeRead.Read()) { Question QQ = new Question(); QQ.Id = ObjeRead.GetString(0); QQ.Enoncer = ObjeRead.GetString(1); QQ.flag = ObjeRead.GetString(2); QQ.Dificulter = ObjeRead.GetString(3); q.Add(QQ); } ObjeRead.Close(); return(View(q)); }
/// <summary> /// SQLSelect: Fait un select sur la connection courante /// et met le resultat dans monReader. La commande /// est passé en paramètre. /// </summary> public void SQLSelect(String maCommandeSQLString) { if ((maCommandeSQLString == null) || (maCommandeSQLString == "")) { throw new JCASQLODPException( "Aucune commande SQL n'a été fournie."); } maCommandeSQL.Connection = maConnection; maCommandeSQL.CommandText = maCommandeSQLString; maCommandeSQL.CommandType = CommandType.Text; try { monReader = maCommandeSQL.ExecuteReader(); monReader.Read(); } catch (OracleException excep) { if (ExceptionDetaillee) throw new JCASQLODPException("Commande SQL:" + Environment.NewLine + maCommandeSQLString + Environment.NewLine + excep.Message, excep); else throw excep; } if (ActiverResume) Resumer(); }