Click here to Skip to main content
Click here to Skip to main content
Articles » Web Development » ASP.NET » General » Downloads
 

YaBlogEngine - A Tiny Blog Engine written in ASP.NET/C#

By , 9 Feb 2012
 
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

namespace YABlog.DAL
{
    public class CategoriesDb
    {

        public CategoriesDb()
        {

        }

        public DataTable GetCategories()
        {
            return Functions.ExecuteSelectCommand("GetCategories");
        }

        public int GetCategoryIdByName(string catName)
        {
            SqlParameter par = new SqlParameter("@cat", catName);
            DataTable table = Functions.ExecuteParamerizedSelectCommand("GetCategoryIdByName", new SqlParameter[] { par });

            return (int)table.Rows[0][0];
        }

        public string GetCategoryNameById(int catId)
        {
            SqlParameter par = new SqlParameter("@id", catId);
            DataTable table = Functions.ExecuteParamerizedSelectCommand("GetCategoryNameById", new SqlParameter[] { par });

            return (string)table.Rows[0][0];
        }

        public bool UpdateCategory(int id, string newName)
        {
            SqlParameter par = new SqlParameter("@id", id);
            SqlParameter par2 = new SqlParameter("@newName", newName);

            return Functions.ExecuteNonQuery("UpdateCategory", new SqlParameter[] { par, par2 });
        }

        public bool AddCategory(string name)
        {
            SqlParameter par = new SqlParameter("@name", name);

            return Functions.ExecuteNonQuery("AddCategory", new SqlParameter[] { par });
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of use and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Rahul Rajat Singh
Software Developer (Senior)
India India
I Started my Programming career with C++. Later got a chance to develop Windows Form applications using C#. Currently using C#, ASP.NET & ASP.NET MVC to create Information Systems, e-commerce/e-governance Portals and Data driven websites.

My interests involves Programming, Website development and Learning/Teaching subjects related to Computer Science/Information Systems. IMO, C# is the best programming language and I love working with C# and other Microsoft Technologies.
Follow on   Twitter

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130617.1 | Last Updated 9 Feb 2012
Article Copyright 2012 by Rahul Rajat Singh
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid