Esempio n. 1
0
        public SqlDataReader returnare_intrebari(string v)
        {
            string query = null;
            Random ran   = new Random();
            int    ranN;
            var    par = new[] { new SqlParameter() };

            if (v == "toate")
            {
                query = "SELECT * FROM dbo.Intrebari";
                par   = null;
                Intrebari c = new Intrebari();
            }
            else if (v == "random")
            {
                SqlDataReader lung;
                int           ab = 0;
                lung = conexiune.executeSelectQueryt("SELECT COUNT(*) FROM dbo.Intrebari", null);
                while (lung.Read())
                {
                    ab = Int32.Parse(lung[0].ToString());
                }
                lung.Close();
                ranN  = ran.Next(1, ab);
                par   = new[] { new SqlParameter("@random", ranN) };
                query = "SELECT * FROM dbo.Intrebari INNER JOIN dbo.Raspunsuri ON dbo.Intrebari.id_intrebare=dbo.Raspunsuri.id_intrebare WHERE dbo.Intrebari.id_intrebare= @random ";
            }
            SqlDataReader crr;

            crr = conexiune.executeSelectQueryt(query, par);
            return(crr);
        }
Esempio n. 2
0
        public SqlDataReader returnare_intrebari(string v)
        {
            string query = null;
            Random ran = new Random();
            int ranN;
            var par = new[] { new SqlParameter() };
            if (v == "toate")
            {
                query = "SELECT * FROM dbo.Intrebari";
                par = null;
                Intrebari c = new Intrebari();

            }
            else if (v == "random")
            {
                SqlDataReader lung;
                int ab = 0;
                lung = conexiune.executeSelectQueryt("SELECT COUNT(*) FROM dbo.Intrebari", null);
                while (lung.Read())
                {
                    ab = Int32.Parse(lung[0].ToString());
                }
                lung.Close();
                ranN = ran.Next(1, ab);
                par = new[] { new SqlParameter("@random", ranN) };
                query = "SELECT * FROM dbo.Intrebari INNER JOIN dbo.Raspunsuri ON dbo.Intrebari.id_intrebare=dbo.Raspunsuri.id_intrebare WHERE dbo.Intrebari.id_intrebare= @random ";


            }
            SqlDataReader crr;
            crr = conexiune.executeSelectQueryt(query, par);
            return crr;


        }