Пример #1
0
        public static bool InsertStream(TStream stream)
        {
            SqlConnection cn  = new SqlConnection(ConfigurationManager.ConnectionStrings["SQL Server"].ConnectionString);
            SqlCommand    cmd = new SqlCommand("createNewStream", cn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@StreamName", SqlDbType.VarChar).Value = stream.StreamName;
            cmd.Parameters.Add("@StreamPoints", SqlDbType.Int).Value   = stream.StreamRank;
            cmd.Parameters.Add("@StreamIsBanned", SqlDbType.Bit).Value = stream.StreamIsBanned;



            try
            {
                cn.Open();
                cmd.ExecuteNonQuery();
            }
            catch (Exception exc)
            {
                exc.ToString();
            }
            finally
            {
                cn.Close();
            }
            return(false);
        }
Пример #2
0
        private void DisplayPopularStreams()
        {
            App_Code.TStream streams = new App_Code.TStream();


            DataTable dt = App_Code.TStream.getPopularStreams();

            btnStream1.Text = dt.Rows[0]["StreamName"].ToString();
            btnStream2.Text = dt.Rows[1]["StreamName"].ToString();
            btnStream3.Text = dt.Rows[2]["StreamName"].ToString();
            btnStream4.Text = dt.Rows[3]["StreamName"].ToString();
            btnStream5.Text = dt.Rows[4]["StreamName"].ToString();
            btnStream6.Text = dt.Rows[5]["StreamName"].ToString();

            selectedStream     = btnStream1.Text;
            hfStreamName.Value = selectedStream;
        }
Пример #3
0
        public static bool UpdateStreamInfo(TStream stream)
        {
            SqlConnection cn  = new SqlConnection(ConfigurationManager.ConnectionStrings["SQL Server"].ConnectionString);
            SqlCommand    cmd = new SqlCommand("updateStreamByStreamID", cn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@StreamID", SqlDbType.Int).Value       = stream.StreamID;
            cmd.Parameters.Add("@StreamName", SqlDbType.VarChar).Value = stream.StreamName;
            cmd.Parameters.Add("@StreamPoints", SqlDbType.Int).Value   = stream.StreamRank;
            cmd.Parameters.Add("@StreamIsBanned", SqlDbType.Bit).Value = stream.StreamIsBanned;


            // Open the database connection and execute the command
            try
            {
                //opens connection to database, most failures happen here
                //check connection string for proper settings
                cn.Open();

                //data adapter object is trasport link between data source and
                //execute the non-query stored procedure
                cmd.ExecuteNonQuery();
                //id = Convert.ToInt32(cmd.Parameters["@BattleID"].Value);
            }
            catch (Exception exc)
            {
                //just put here to make debugging easier, can look at error directly
                exc.ToString();
            }
            finally
            {
                //must always close connections
                cn.Close();
            }

            bool isUpdated = false;

            return(isUpdated);
        }