示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            db = new DatabaseMethods();

            if (Session["Login"] == null)
            {
                if (db.OpenConnection() != null)
                {
                    lbl_Error.Visible = false;
                }
                else
                {
                    lbl_Error.Visible = true;
                    lbl_Error.Text = "SQL Connection Error";
                }
                db.CloseConnection();
            }
            else
            {
                if (Session["Login"].ToString() != "1")
                {
                    lbl_Error.Visible = true;
                    lbl_Error.Text = "Session State Error";
                    db.CloseConnection();
                }
                else
                {
                    db.CloseConnection();
                    Response.Redirect("WebForm1.aspx");
                }
            }
        }
 void GetContent(String id)
 {
     DatabaseMethods db = new DatabaseMethods();
     db.OpenConnection();
     //rpt_Icerik.DataSource = db.GetDataReader("Select Baslik , Icerik from Makale Where MakaleId =" + a);
     rpt_Icerik.DataSource = db.GetDataTable("Select Baslik , Icerik from Makale Where MakaleId =" + a);
     rpt_Icerik.DataBind();
     db.CloseConnection();
 }
 protected void rptMakaleOzet_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     DatabaseMethods db = new DatabaseMethods();
     db.OpenConnection();
     DataList dl1 = (DataList)e.Item.FindControl("dl_Tags");
     dl1.DataSource = db.GetDataTable("SELECT e.EtiketAd FROM Makale m , MakaleEtiket me , Etiket e WHERE me.MakaleId = m.MakaleId AND me.EtiketId = e.EtiketId AND m.MakaleId = " + DataBinder.Eval(e.Item.DataItem, "MakaleId").ToString());
     dl1.DataBind();
     db.CloseConnection();
 }
        DataTable MakaleOzetGetir()
        {
            DatabaseMethods db = new DatabaseMethods();
            db.OpenConnection();
            DataSet ds = db.GetDataset("SELECT m.MakaleId , Baslik , m.Tarih , Ozet , Count(y.MakaleID) " +
                                                " as Yorum_Count FROM Makale m LEFT JOIN Yorum y " +
                                                "ON m.MakaleId = y.MakaleID GROUP BY m.MakaleId , Baslik , m.Tarih , Ozet" +
                                                " ORDER BY m.Tarih DESC");

            rptMakaleOzet.DataSource = ds.Tables[0];
            rptMakaleOzet.DataBind();
            db.CloseConnection();
            return ds.Tables[0];
        }