Friday, March 27, 2009

Cursor for get all the table name in database

This cursor is used for get all the table name form database.
and we can simply add the sql commands in this cursor. as
I shown in Print Statement.

Declare @t varchar (1024)
Declare tbl_cur cursor for
select TABLE_NAME from INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' order by TABLE_NAME
OPEN tbl_cur
FETCH NEXT from tbl_cur INTO @t
WHILE @@FETCH_STATUS = 0
BEGIN
-- print ('sp_rename '+ @t +','+@t+'Notused')
print ('select * from '+ @t )
print 'GO'
FETCH NEXT from tbl_cur INTO @t
END
CLOSE tbl_cur
DEALLOCATE tbl_Cur

Thanks
HELPONDESK TEAM

Thursday, March 19, 2009

steps to set minimum and maxumum length of passwerd

Hi
This is simple steps to set minimum and maxumum length of passwerd.


Step 1) For Req. filed

[asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtpassword" Display="None"
ErrorMessage="Your password is a required field."][/asp:RequiredFieldValidator]

Step 2) For set Min n Max length of password.


[asp:RegularExpressionValidator ID="RegularExpressionValidator7" runat="server"
ControlToValidate="txtpassword" Display="None"
ErrorMessage="password shuld be 6-32 characters" ValidationExpression="\w{6,}"][/asp:RegularExpressionValidator]


Thanks
Helpondesk Team

Saturday, March 14, 2009

funcition for calculating distacne from langitude and latetude.

private double distance(double lat1, double lon1, double lat2, double lon2, string unit)
{
double totalDistance;
double theta, dist;
theta = lon1 - lon2;
dist = Math.Sin(deg2rad(lat1)) * Math.Sin(deg2rad(lat2)) + Math.Cos(deg2rad(lat1)) * Math.Cos(deg2rad(lat2)) * Math.Cos(deg2rad(theta));
dist = acos(dist);
dist = rad2deg(dist);
totalDistance = dist * 60 * 1.1515;
if (unit == "K")
{
totalDistance = totalDistance * 1.609344;
return totalDistance;
}
else if (unit == "N")
{
totalDistance = totalDistance * 0.8684;

return totalDistance;

}
else
{
return 0.00;
}


}

private double acos(double rad)
{
if (Math.Abs(rad) != 1)
{
return pi / 2 - Math.Atan(rad / Math.Sqrt(1 - rad * rad));

}
else if (rad == -1)
{
return pi;
}
else
{
return 0.00;

}



}

private double deg2rad(double Deg)
{
return Convert.ToDouble(Deg * pi / 180);
}

private double rad2deg(double Rad)
{
return Convert.ToDouble(Rad * 180 / pi);
}

Friday, March 13, 2009

Delete Duplicate Records -- Without having Primary key

-----------Delete Duplicate Records ---------------------------
-------- Without having Primary key ---------------------------
CREATE TABLE [SalesHistory]
( [Product] [varchar](10) NULL,
[SaleDate] [datetime] NULL,
[SalePrice] [money] NULL )
GO
INSERT INTO SalesHistory(Product, SaleDate, SalePrice)
SELECT 'Computer','1919-03-18 00:00:00.000',1008.00
UNION ALL
SELECT 'BigScreen','1927-03-18 00:00:00.000',91.00
UNION ALL
SELECT 'PoolTable','1927-04-01 00:00:00.000',139.00
UNION ALL
SELECT 'Computer','1919-03-18 00:00:00.000',1008.00
UNION ALL
SELECT 'BigScreen','1927-03-18 00:00:00.000',91.00
UNION ALL
SELECT 'PoolTable','1927-04-01 00:00:00.000',139.00





set rowcount 1
select 'start'
while @@rowcount > 0
begin

delete a from SalesHistory a
where
(
select count(*) from saleshistory b

where a.product = b.product and a.saledate = b.saledate and a.SalePrice = b.SalePrice)>1
end

set rowcount 0

select product,saledate, SalePrice from SalesHistory

Thursday, March 12, 2009

Whats new in ASP.NET 3.5

Whats new in ASP.NET 3.5
Some important featues which are introduce in with framework 3.5
ASP.NET AJAX
In ASP.NET 2.0, ASP.NET AJAX was used as an extension to it. You had to download the extensions and install it. However in ASP.NET 3.5, ASP.NET AJAX is integrated into the .NET Framework, thereby making the process of building cool user interfaces easier and intuitive.
The integration between webparts and the update panel is much smoother. Another noticeable feature is that you can now add ASP.NET AJAX Control Extenders to the toolbox in VS2008. Even though this is an IDE specific feature, however I feel it deserves a mention over here for developers, who had to add extenders using source view earlier. It is also worth noting that Windows Communication Foundation (WCF) now supports JSON along with other standard protocols like SOAP, RSS and POX.
New Controls
The ListView and DataPager are new controls added along with a new datasource control called the LinqDataSource.
ListView
The ListView control is quiet flexible and contains features of the Gridview, Datagrid, Repeater and similar list controls available in ASP.NET 2.0. It provides the ability to insert, delete, page (using Data Pager), sort and edit data. However one feature of the ListView control that stands apart, is that it gives you a great amount of flexibility over the markup generated. So you have a complete control on how the data is to be displayed. You can now render your data without using thetag. You also get a rich set of templates with the ListView control.
DataPager
DataPager provides paging support to the ListView control. The best advantage is that you need not have to keep it ‘tied’ with the control on which the paging is being done. You can keep it anywhere on the page.
DataPager gives you a consistent way of paging with the controls that support it. Currently only ListView supports it as it implements the IPageableItemContainer. However support is likely to be added to other List controls as well.
LINQ
LINQ (Language Integrated Query) adds native data querying capability to C# and VB.NET along with the compiler and Intellisense support. LINQ is a component of .NET 3.5. LINQ defines operators that allow you to code your query in a consistent manner over databases, objects and XML. The ASP.NET LinqDataSource control allows you to use LINQ to filter, order and group data before binding to the List controls.
ASP.NET Merge Tool
ASP.NET 3.5 includes a new merge tool (aspnet_merge.exe). This tool lets you combine and manage assemblies created by aspnet_compiler.exe. This tool was available earlier as an add-on.
New Assemblies
The new assemblies that would be of use to ASP.NET 3.5 developers are as follows:
System.Core.dll - Includes the implementation for LINQ to Objects
System.Data.Linq.dll - Includes the implementation for LINQ to SQL
System.Xml.Linq.dll - Includes the implementation for LINQ to XML
System.Data.DataSetExtensions.dll - Includes the implementation for LINQ to DataSet
System.Web.Extensions.dll: Includes the implementation for ASP.NET AJAX (new enhancements added) and new web controls as explained earlier.
Some other important points for move to asp.net 3.5
ASP.NET 3.5 provides better support to IIS7. IIS7 and ASP.NET 3.5 modules and handlers support unified configuration.
You can have multiple versions of ASP.NET on the same machine.
For those who are wondering what happened to ASP.NET 3.0, well there isn’t anything called ASP.NET 3.0.
VS 2002 worked with ASP.NET 1.0, VS 2003 worked with ASP.NET 1.1, and VS 2005 worked with ASP.NET 2.0. However VS 2008 supports multi-targeting, i.e it works with ASP.NET 2.0, and ASP.NET 3.5.
Intellisense with javaScript for rapid developement.
Addin system p2p base class Active directory Anonymous types with static type inference Paging support for ADO.NET ADO.NET synchronization API to synchronize local caches and server side datastores Asynchronous network I/O API Support for HTTP pipelining and syndication feeds. New System.CodeDom namespace.