Posts

Showing posts from May, 2012

Reading membership section from web.config in C#

        MembershipSection membershipSection = ( MembershipSection ) WebConfigurationManager . GetSection ( "system.web/membership" );         string defaultProvider = membershipSection . DefaultProvider ;         ProviderSettings providerSettings = membershipSection . Providers [ defaultProvider ];         string connectionStringName = providerSettings . Parameters [ "connectionStringName" ];         string connectionUsername = providerSettings . Parameters [ "connectionUsername" ];         string connectionPassword = providerSettings . Parameters [ "connectionPassword" ];         string connectionString = WebConfigurationManager . ConnectionStrings [ connectionStringName ]. ConnectionString ;

SQL Server PowerShell Overview

SQL Server 2008 introduces support for Windows PowerShell. Windows PowerShell is a powerful scripting shell that lets administrators and developers automate server administration and application deployment. The Windows PowerShell language supports more complex logic than Transact-SQL scripts, giving SQL Server administrators the ability to build robust administration scripts. Windows PowerShell scripts can also be used to administer other Microsoft server products. This gives administrators a common scripting language across servers. SQL Server provides two Windows PowerShell snap-ins that implement: A SQL Server provider, which enables a simple navigation mechanism similar to file system paths. You can build paths similar to file system paths, where the drive is associated with a SQL Server management object model, and the nodes are based on the object model classes. You can then use familiar commands such as cd a...

Configuring & Checking CLR integration in SQL Server

Now we are going to configure the CLR, by enabling it. Enable Set 1 Disable Set 0 sp_configure   'show advanced options' ,  1 ; GO RECONFIGURE ; GO sp_configure   'clr enabled' ,  1 ; GO RECONFIGURE ; GO Disabling  sp_configure   'show advanced options' ,  1 ; GO RECONFIGURE ; GO sp_configure   'clr enabled' ,  0 ; GO RECONFIGURE ; GO Check whether the CLR is enabled or not using the below query: SELECT   *   FROM   sys . configurations   WHERE  name  =   'clr enabled' Add your DLL in SQL Assembly:   CREATE ASSEMBLY cbtestassembly FROM 'C:\cb\TestCb.dll' WITH PERMISSION_SET = UNSAFE;

Find total salary by employee without group by

emp_id name salary 1 chandra 10000.00 1 chandra 20000.00 2 sanjay 30000.00 2 sanjay 47000.00 3 ashutosh 39087.00 4 Teji          NULL select emp_id,name,sum(salary) over (partition by emp_id) totsal from emp_sal_tbl

How to Get TimeZoneInfo list in C#

using System.Web.Security; using System.Collections.ObjectModel; using System.Web; ReadOnlyCollection<TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones();                 List<UTCList> lstUTCList = new List<UTCList>();                 foreach (TimeZoneInfo timeZone in timeZones)                 {                     lstUTCList.Add(new UTCList() { Name = timeZone.DisplayName, ID = timeZone.Id });                 }                 SelectList objSelectList = new SelectList(lstUTCList, "ID", "Name", "India Standard Time");  Session["List of Data"] = objSelectList; public class UTCList         {             public string Name { get; s...

How to bind and call selected event of dropdownlist in MVC 3

//Bind dropdown on layout page @if (Session["List of data"] != null)                 {                     @Html.DropDownList("Dropdown ID", Session["List of data"] as SelectList)                 } then create controler and write your business logic. //Dropdown change event on Layout(master) //calling controler <script type='text/javascript'>     $(document).ready(function () {         $('#Dropdown ID').change(function () {             var v1 = $(this).val();             if (v1 != $('#hidden control ID').val()) {                 var url = '/controler name/action name/' + v1;                 window.location.replace(url);             ...

Detecting Client Side Time Zone Offset Via Javascript

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript">     function get_time_zone_offset() {         var current_date = new Date();         var gmt_offset = current_date.getTimezoneOffset() / 60;         return gmt_offset;     }     $('#offset').html(get_time_zone_offset()); </script>

Find table's by column name in sqlserver

SELECT t.name AS table_name, SCHEMA_NAME(schema_id) AS schema_name, c.name AS column_name FROM sys.tables AS t INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID WHERE c.name LIKE '%Column name%' ORDER BY schema_name, table_name;

Check out this great MSN video: Crazy Guy Handles Cobras

Check out this great MSN video: Crazy Guy Handles Cobras

different in Response.RedirectPermanent method and Response.Redirect

ets say that I have a page called "page1.aspx", and  google cached it in his database search, now if I changed the page1.aspx or I removed it, then I need to put the Response.RedirectPermanent("Page2.aspx) in the page load of Page1.aspx, so that google next time will know that Page1.aspx has become Page2.aspx. In the backend, http protocol supports 2 ways of redirections, 301 and 302. Permanant redirect send 301 response code to the browser "301 redirects are permanent. They mean that the page has moved, and they request any search engine or user agent coming to the page to update the URL in their database. This is the most common type of redirect that people should use." Response.RedirectPermanent  do the same thing as following code does.         Response.Status = "301 moved permanently";         Response.AddHeader("location", newPath);         Response.End(); Response.RedirectParmanent is an...