<file_sep>﻿using System;
using System.Data;
using System.Data.SqlClient;

public partial class write : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ourdb"].ConnectionString);
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }

            SqlCommand cmd = new SqlCommand("insert into BlogPost(Title,Content,Author, BlogDate) values(@title,@content,@author,@date)", con);
            cmd.Parameters.AddWithValue("@title", txbxTitle.Text);
            cmd.Parameters.AddWithValue("@content", txbxContent.Text);
            cmd.Parameters.AddWithValue("@author", txbxAuthor.Text);
            cmd.Parameters.AddWithValue("@date", System.DateTime.Now);
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            Response.Write("done!!!!!!");
        }
        catch (Exception k)
        {
            Response.Write(k.Message);
            //throw;
        }
        finally { con.Close(); }
    }
}<file_sep>﻿using System;
using System.Data;
using System.Data.SqlClient;

public partial class details : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ourdb"].ConnectionString);
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString.Get("Id") != null)
        {
            DetailsView1.DefaultMode = System.Web.UI.WebControls.DetailsViewMode.ReadOnly;
            detail();
            bindComment();
        }
    }

    void detail()
    {
        try
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            SqlCommand cmd = new SqlCommand("select * from BlogPost where Id=@id", con);
            cmd.Parameters.AddWithValue("@id", Request.QueryString["Id"]);
            SqlDataAdapter adp = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            adp.Fill(ds);
            ds.Tables[0].Columns.Add("FormDate", typeof(string));
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                DateTime date = (DateTime)ds.Tables[0].Rows[0]["BlogDate"];
                string format = "MMM ddd d, yyyy";
                ds.Tables[0].Rows[0]["FormDate"] = date.ToString(format);
            }
            DetailsView1.DataSource = ds;
            DetailsView1.DataBind();
            cmd.Dispose();
        }
        catch (Exception k)
        {
            Response.Write(k.Message);
            //throw;
        }
        finally
        {
            con.Close();
        }
    }

    void bindComment()
    {
        try
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }

            SqlCommand cmd = new SqlCommand("select * from Comments where BlogId=@id", con);
            cmd.Parameters.AddWithValue("@id", Request.QueryString["Id"]);
            SqlDataAdapter adp = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            adp.Fill(ds);
            if (ds.Tables[0].Rows.Count == 0)
            {
                GridViewcomment.Visible = false;
                LabelNoComment.Visible = true;
            }
            else
            {
                GridViewcomment.Visible = true;
                LabelNoComment.Visible = false;
                GridViewcomment.DataSource = ds;
                GridViewcomment.DataBind();
            }

        }
        catch (Exception)
        {

            throw;
        }
        finally { con.Close(); }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            if (txbxcomment.Text != txbxcomment.ToolTip.ToString() || txbxcommentauthor.Text != txbxcommentauthor.ToolTip.ToString())
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }

                SqlCommand cmd = new SqlCommand("insert into Comments(BlogId, Comment, Name, Date) values(@bid,@com,@name,@date)", con);
                cmd.Parameters.AddWithValue("@bid", Request.QueryString["Id"]);
                cmd.Parameters.AddWithValue("@com", txbxcomment.Text);
                cmd.Parameters.AddWithValue("@name", txbxcommentauthor.Text);
                cmd.Parameters.AddWithValue("@date", System.DateTime.Now);
                cmd.ExecuteNonQuery();
                cmd.Dispose();
                txbxcomment.Text = String.Empty;
                txbxcommentauthor.Text = String.Empty;
                bindComment();
            }
            else
            {

            }

        }
        catch (Exception)
        {

            throw;
        }
        finally { con.Close(); }
    }
}
<file_sep>
News Article using Blogging techniques which is built ASP.NET with the help of MS SQL DB and MS SQL Server 2014 where it is hosted in Microsoft Azure making use of remote SQL Server v12 in which it is remotely published using MS Visual Studio 2015.
<file_sep>﻿using System;
using System.Data;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ourdb"].ConnectionString);
    protected void Page_Load(object sender, EventArgs e)
    {
        BindBlog();
    }

    void BindBlog()
    {
        try
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }

            SqlCommand cmd = new SqlCommand("select * from BlogPost order by BlogDate desc ", con);
            SqlDataAdapter adp = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            adp.Fill(ds);
            GridView1.DataSource = ds;
            GridView1.DataBind();
            cmd.Dispose();
        }
        catch (Exception k)
        {
            Response.Write(k.Message);
            //throw;
        }
        finally
        {
            con.Close();
        }

    }
}