November 2013 | Coding Cluster - using, c#, mvc 4, iphone, php, ios, javascript, in mvc 3 & more

Enabling Service Broker in SQL Server 2008


Activate  Service Broker in SQL Server 2008:
                          If you are working in sql dependency, SignalR related projects you must enable service broker for  messaging and queuing functions between instances. The basic functions of sending and receiving messages forms a part of a “conversation.”

What is services broker?
                        According  from Microsoft SQL Server Service Broker provides native support for messaging and queuing applications in the SQL Server Database Engine. This makes it easier for developers to create sophisticated applications that use the Database Engine components to communicate between disparate databases. Developers can use Service Broker to easily build distributed and reliable applications.

                        Service broker find applications when single or multiple SQL server instances are used. This functionality helps in sending messages to remote databases on different servers and processing of the messages within a single database. In order to send messages between the instances, the Service Broker uses TCP/IP.

Check the sql server services broker status?
                          Before enable service broker better  we need check the current services broker status of the database. The following simple command used to do that.

SELECT name, is_broker_enabled FROM sys.databases

Then activate services broker on "codingclusterDB" database by using the following command.


Enable SQL Server Broker taking too long time?
                                         If your Alter Database query takes long time to process, then use the following command to activate services broker on your database


Install .nupkg file locally(OR)Offline in visual studio from NuGet


Install NuGet Package from local machine manually:
              Some  companies  not allowed internet connection for development environment for some security purpose. On that time we can't install packages directly  from Nuget.Org  through  Package Manager console. This type of situation the following s three easy steps to install Nuget packages to visual studio when your are working in offline mode.

Step-1: First download your package from

Download Nuget Packages Without VS/NuGet Package Manager (Manuallydownload): 
                 If you not able to directly download the package from , then you try a chrome extension called  "NuTake". This extension create a direct link to download the package. The link just shown  under the "PM>Install - Package..." command box.

Step-2: After download your package open visual studio and open "Tools - > Options -> Package Manager"


Give a name and folder location. Click OK. Drop your NuGet package files in that folder.

Step-3: In the third step, Go to your Project, Right click and select "Manage Nuget Packages" and

select /Install  your new Package source.

Sample code for displaying festival names on calendar control in ASP.Net


Displaying festival names on calendar control using c# in ASP.Net:

                                          This is an article for showing festival names on a specific date on calendar control. First create a SQL table with following fields HolidayName, HolidayDate. And fulfill the festival name in "HolidayName" field and festival date in "HolidayDate" field.

Then  took one Calendar control on to the page(Calendar.aspx)

Copy and  paste the following code into your Calendar.aspx file

 <form id="form1" runat="server">

    <asp:calendar ondayrender="Calendar1_DayRender" id="Calendar1" runat="server" backcolor="#FFFFCC" bordercolor="#FFCC66" borderwidth="1px" daynameformat="Shortest" names="Verdana" size="8pt" forecolor="#663399" height="200px" showgridlines="True" width="300px">
        <selecteddaystyle backcolor="#CCCCFF" bold="True">
        <selectorstyle backcolor="#FFCC66">
        <todaydaystyle backcolor="#FFCC66" forecolor="White">
        <othermonthdaystyle forecolor="#CC9966">
        <nextprevstyle size="9pt" forecolor="#FFFFCC">
        <dayheaderstyle backcolor="#FFCC66" bold="True" height="1px">
        <titlestyle backcolor="#990000" bold="True" size="9pt" forecolor="#FFFFCC">

<span style="font-weight: bold; color: rgb(51, 51, 255);font-size:130%;"></span>

Then Copy and  paste the following code into your Calendar.aspx.cs file

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
SqlConnection con;
protected void Page_Load(object sender, EventArgs e)
 con = new SqlConnection(ConfigurationManager.ConnectionStrings["YourConnectionString"].ConnectionString);
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
 CalendarDay day = (CalendarDay)e.Day;
 SqlCommand cmd = new SqlCommand("select HolidayName,HolidayDate from Holidays", con);
 SqlDataReader dr = cmd.ExecuteReader();

 while (dr.Read())
     if (day.Date.ToString() == dr["HolidayDate"].ToString())
         TableCell cell = (TableCell)e.Cell;
         string s1 = dr["HolidayName"].ToString();
         if (s1 != null)
             cell.BackColor = System.Drawing.Color.LightGray;
             cell.Controls.Add(new LiteralControl("
" + s1));


That's all finally build and run your page you will see a calender control with festival name.




Blogger Widgets