Monday, November 10, 2008

Difference between .net3.0 and .net 2.0

Hi
with .NET 2.0, the CLR works on a relatively simple concept: A common runtime model executes code for any system running the .NET Framework.
Version 3.0 of the .NET Framework is the first release that doesn’t improve on the Common Language Runtime.The .NET 3.0 Framework isn’t improving upon existing technologies but rather introducing four new foundation technologies:
* Windows Presentation Foundation (WPF)
* Windows Communication Foundation (WCF)
* Windows Workflow Foundation (WWF)
* Windows CardSpace (WCS)

Windows Presentation Foundation (WPF)

Windows Presentation Foundation (WPF) is arguably the most well-known of the four new foundation class sets. This is largely because of two things:

* You can actually see a WPF solution.
* WPF has been compared frequently to Adobe’s Flash
WPF is a consistent programming model for building solutions, and enables the use of richer controls, design, and development in Windows programs. A WPF program can be developed and released to desktops, the Web, and devices.Once interesting aspect of WPF is the XML standard programming language called XAML (pronounced "Zammel") that controls the layout of objects

Windows Communication Foundation

The core purpose of the Windows Communication Foundation (WCF) is to allow programs to talk to other programs on the same computer or network, or across the Internet. The WCF programming model unifies web services, .NET Remoting, distributed transactions, and message queues into a single service-oriented programming model for distributed computing.WCF is designed in accordance with service-oriented architecture principles to support distributed computing, in which services are used by consumers, clients can consume multiple services, and services can be consumed by multiple clients. Services typically have a WSDL interface that any WCF client can use to consume the service, irrespective of the platform on which the service is hosted.

Windows Workflow Foundation

Windows Workflow Foundation (WWF) is a Microsoft technology for defining, executing, and managing workflows. Workflows are composed of activities; developers can write their own domain-specific activities and then use them in workflows

WindowsCardSpace

Windows CardSpace, originally code-named "InfoCard," lets any Windows application, including Microsoft technologies such as the next release of Internet Explorer and those created by others, give its users a common way to work with digital identitiesThe goal is to let people on any machine, running any operating system, use digital identities as easily, as effectively, and as securely as they today use their identities in the physical world.

Find All Stored Procedure in SqlTable

Following code will help to find all the Stored Procedures (SP) which are related to one or more specific tables. sp_help and sp_depends does not always return accurate results.

   ----Option 1
SELECT DISTINCT so.name
FROM syscomments sc
INNER JOIN sysobjects so ON sc.id=so.id
WHERE sc.TEXT LIKE '%tablename%'
----Option 2
SELECT DISTINCT o.name ,o.xtype
FROM syscomments c
INNER JOIN sysobjects o ON c.id=o.id
WHERE c.TEXT LIKE '%tablename%'

Thursday, September 18, 2008

Add Dynamic Column in SQL

Hi,
Here is the Code to Add column dynamically in a table

Declare @ColumnName as Varchar(50)
declare @ssql nvarchar(200)
Set @ColumnName ='Column1'
set @ssql = 'Alter table TableName Add ' + @ColumnName + ' int'
exec sp_executesql @ssql



Here is the code to add dynamic column with data type

Declare @ColumnName as Varchar(50)
declare @ssql nvarchar(200)
declare @DataType
nvarchar(200)

Set @ColumnName ='Column1'
Set @
DataType ='Bigint'
set @ssql = 'Alter table TableName Add ' + @ColumnName + ' ' +@DataType
exec sp_executesql @ssql


Tuesday, September 16, 2008

Remove ?xml version="1.0" encoding="utf-8"? in c#

Hi,
Here is the code to remove xml header

public class XmlTextWriterFormattedNoDeclaration : System.Xml.XmlTextWriter
{
public XmlTextWriterFormattedNoDeclaration(System.IO.TextWriter w): base(w)
{
Formatting = System.Xml.Formatting.Indented;
}

public override void WriteStartDocument() { } // suppress
}
Then you can serialize like this

XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add("", "");
XmlSerializer serializer = new XmlSerializer(typeof(object));
StringWriter sw = new StringWriter();
XmlWriter writer = new XmlTextWriterFormattedNoDeclaration(sw);
serializer.Serialize(writer, this, ns);



Wednesday, September 10, 2008

Difference Between Rank and DenseRank in Sql

Hi,
Here is the differnce between  Rank() and DenseRank() function
Consider Below  Table Employee Which is ordered by salary
Table Name: Employee
EmpId         Name         Salary
 1  John       100
 2               Jenny           170
 3               Mac             170
 4               Millon 350

Here is the query to rank employee by salary

Select *, Dense_RANK() over(order by Salary) As DenseRank,RANK() over(order by Salary) As Rank From Employee  


Now the tablewill be
EmpId           Name            Salary       Rank     DenseRank
 1                John             100          1             1
 2                 Jenny             170          2             2
 3                 Mac                170         2             2
 4                 Millon  350         4             3


Dense Rank last value will be the total unique value in table


Friday, September 5, 2008

Cropping and Resizing Image in c#

Hi,
Here is the best link to crop and resize the image step by step process
http://blog.paranoidferret.com/?p=11

Merge Image in c#

Hi,
Here is the code to merge image in c#
// Create a new image
Image img = new Bitmap(300, 100);
// Create image object from existing image
Image img = Image.FromFile("Image.jpg");
Before make changes with img we need to convert it to Graphics object: 
Graphics g = Graphics.FromImage(img);
// Place a.gif
g.DrawImage(Image.FromFile("a.gif"), new Point(10, 10));
// Save changes as output.jpg
img.Save("output.jpg", ImageFormat.Jpeg);