Wednesday, January 6, 2010

Connection pooling in ADO.NET

Connection pooling enables an application to use a connection from a pool of connections that do not need to be re-established for each use. Once a connection has been created and placed in a connection pool, an application can reuse that connection without performing the complete connection creation process.

By default, the connection pool is created when the first connection with a unique connection string connects to the database. The pool is populated with connections up to the minimum pool size. Additional connections can be added until the pool reaches the maximum pool size.

When a user request a connection, it is returned from the pool rather than establishing new connection and, when a user releases a connection, it is returned to the pool rather than being released. But be sure than your connections use the same connection string each time. Here is the Syntax

conn.ConnectionString = "integrated Security=SSPI; SERVER=192.168.0.123; DATABASE=MY_DB; Min Pool Size=4;Max Pool Size=40;Connect Timeout=14;";

ASP.NET 3.5 with VS2008


Tuesday, January 5, 2010

Job Openings



Friday, December 18, 2009

Sharing Viewdata across Actions in ASP.NET MVC


Use TempData instead of ViewData:


public ActionResult Index()
{
ViewData["message"] = TempData["message"];
return View();
}


public ActionResult AddProduct()
{
TempData["message"] = "product created";
return RedirectToAction("Index");
}


And in the Index view:


<% if (TempData["message"] != null) { %>
<%= Html.Encode((string)TempData["message"]) %>
<% } %>

Monday, November 30, 2009

Live cricket scorecard

C# : Print Dialog

PrintDialog ppdlg = new PrintDialog();
ppdlg.Document = printDocument;
ppdlg.ShowDialog();

C# : The Leap Year

One of the operations performed on date values is to find out whether the year value of a date is a leap year. Fortunately, the static IsLeapYear() method of the DateTime structure can be used to perform this operation. The syntax of this function is:

public static bool IsLeapYear(int year);

This method takes an integer argument and examines it. If the argument, which must be a valid year number, is a leap year, the method returns true; otherwise, it would return false. Here are two examples:
 
using System;

namespace DateAndTime
{
    class Program
    {
        static int Main()
        {
            DateTime date = new DateTime(1988, 10, 6);
            Console.WriteLine("{0} was a leap year: {1}",
                              date.Year, DateTime.IsLeapYear(date.Year));

            date = new DateTime(1990, 8, 12);
            Console.WriteLine("{0} was a leap year: {1}",
                              date.Year, DateTime.IsLeapYear(date.Year));

            return 0;
        }
    }
}

This would produce:

1988 was a leap year: True
1990 was a leap year: False
Press any key to continue . . .