Posts

Showing posts from October, 2013

Remove duplicate rows from table

By mistakenly , non-primary key table data inserted into SQL Table. what you will do ? We dun have any option without deleting it. If we not used Savepoint , then how to rollback inserted data ? Remove table , --- > No Remove rows one by one --> No Use CTE ( Common Table Expression) Query : I have inserted following data two times insert into [Test] . [dbo] . [Student] values ( 1 , 'nihar' , 'pune' ) insert into [Test] . [dbo] . [Student] values ( 2 , 'rohan' , 'nashik' ) insert into [Test] . [dbo] . [Student] values ( 3 , 'vishal' , 'pabal' ) Remove duplicate rows : Query :    WITH OrderedResults AS ( SELECT [studno] , ROW_NUMBER () OVER ( PARTITION BY [studno] ORDER BY [studno] ) AS RowNumber FROM [Test] . [dbo] . [Student] ) delete from OrderedResults WHERE RowNumber!= 1       Select whole query and execute it,   Duplicate entries will be removed from table. Think over it.  

Temporary tables in SQL Server

Image
Hi friends , Yesterday I thought about temp. tables in database . After searching over same query , I got through some links regarding "Temp Table " , "global temporary table ", "Local Temp Table", "#"  etc. Temporary table created on tempdb of SQL Server. This is a separate database. So, this is an   additional overhead and can causes performance issues. Number of rows and columns need to be as minimum as needed. Tables need to be deleted when they are done with their work.  Till the date I am using simple method to do so . But this concept will save my time and don't confuse between oracle and sql server. Its different. Concept : Temporary tables in Database Concept of temporary table which helps the developer in a great way. These tables can be created at runtime and can do the all kinds of operations that one normal table can do. But, based on the table types, the scope is limited. These tables are created inside system da

ButtonField class in ASP.NET

Image
ButtonField is very well known field of ASP.NET Gridview control. We have seen how to use element to display select, edit and delete buttons in a GridView control. However, if we wish to provide buttons which perform additional custom functionalities, we use the element in a GridView control.   It's part of Data events like DetailView and Gridview under  <Column> <asp : ButtonField ButtonType...... /> </Column>  Description With Example : In the below example, we have used the ButtonField element to add Details button in a row of GridView control. The element displays the button as a link or a button or an Image. Step 1: Declare a GridView control and set the AutoGenerateColumns property to 'false' and set the event handler for the RowCommand event. Step 2: When we click on the Details button, the GridView controls row command event is raised. In this example, the event RowCommand is handled by the GridView1_RowCommand event. <

BaseDataList Control in ASP.NET

Today I seen BaseDataList in MSDN Tutorial. But I am confuse about BaseDataLIst control / class. Is it concept or web form control ? or Is it base class for DataControls in asp.NET ? According to msdn they were showing its similar to DataList and DataGrid controls. BaseDataList description also available from .Net 2.0 to till now. Don't search for BaseDataList in Toolbox of Visual Studio because its a Class and DataList concept. It is not a control, it's an abstract class meaning that it provides base functionality that must be inherited by another class to be used. In this case it provides common functionality for the DataList and DataGrid controls so that methods like GetData and events like SelectedIndexChanged are available to both. Constructor : A BaseDataList object is not created directly. This constructor is commonly called in the constructor of a derived class to initialize the properties defined in the BaseDataList class. Use : Use the Control

Error while running webparts ??? Failure to connect to sql server

Its strange , that while running only aspx page ,its showing error of SQL Server . How ? What ? Why ?. .... Error : The webpartmanager is looking for SQL Express 2005 which, by default, is the personalization provider. We can work around this but if you are really eager to see your page displayed you can set the Personalization-Enabled="false " in the webpartmanager. This will render your page but it will also defeat any purpose of using webparts. For the real solution read on. Solution : 1) Open your visual studio command prompt located in "Start Menu\Programs\Microsoft Visual Studio 2005\Visual Studio Tools\Visual Stuido 2005 Command Prompt" and type in aspnet_regsql.exe. This will launch a wizard so that you can either create a DB or add tables to an existing database for storing personalization infromation. Click Next, Next, then enter in your DBServer Name. Lets leave the DB as "default" for now, click next, next, finish. By leaving

Unable to attach to application 'WebDev.WebServer.EXE'

Image
Type : Its error , while executing application from Visual Studio 2008 Description :   Some times in VS 2008 an error is observed before debugging an application and some times   When I choose yes, the default browser loads forever. Even if I set IE as the default browser, the same error on VWD2005 occurs. Some   Solutions :   A quick solution is to press CTRL+ALT+DEL to open task manager, In processes tab end WebDev.WebServer.EXE or Restart application :)  :)  

Custom Validation Attribute in ASP.NET

Image
Custom Property Validation Attribute Above mentioned value defined as " User defined custom attribute " Normally .Net developers used following types of attribute - Compare - Range - Required - RegularExpression - StringLength - Authorize etc..... MSDN defined namespace - using System.ComponentModel.DataAnnotations; Step 1 : But we are creating our own defined attributes in C# Consider , we want to check weight can't be more than 100 to be entered by end user on web site [Note: Just for your code beautification make folder in solution as Infrastructure or any] I created folder as MVC Infrastructure in solution.   namespace BlogManagement.Infrastructure {     public class RanegDieIdAttribute : RequiredAttribute    {          public override bool IsValid( object value)         {                     return base .IsValid(value) && (( double )value) > 100;           }     } } Step 2: In  Models of MVC project , crea