Pages

Wednesday, December 31, 2008

SELECT Statement Execution in SQL Server

SQL Server uses the following steps to process a single SELECT statement:

1. The parser breaks SELECT statement into logical units, such as keywords, expressions, operators, and identifiers.
2. A query tree is built.
3. The query optimizer then determines the best steps that can return fastest result while consuming the fewest resources.
4. The relational engine begins executing the execution plan, requesting the storage engine to pass up data.
5. The relational engine processes the data returned from the storage engine into the result set format and returns the result set to the client.

Profiling in SQL Server

SQL Profiler captures SQL Server events from a server. The events are saved in a trace file that can be used to analyze and diagnose problem.

The different purposes of using SQL Profiler are:
It is used to find the cause of the problem by stepping through problem queries.
It is very useful to analyze the cause of slow running queries.
It can be used to tune workload of the SQL server.
It also stores security-related actions that can be reviewed by a security administrator.
SQL Profiler also supports auditing the actions performed on instances of SQL Server.

English Query in SQL Server

SQL Server English Query helps to build applications that can accept query in questions form (in English). The application passes the questions string to the English query engine. English Query then returns to the application a SQL statement or a Multi-Dimensional Expression (MDX) query that will return the answer to the user’s question.

Rename Column in SQL Server

The following sample code demonstrates how to rename a column in SQL server using the stored procedure

EXEC sp_rename @objname = '[TableName].OldColumnName',
@newname = 'NewColumnName',
@objtype = 'COLUMN'

Reverse String in C#

Normally we write FOR loop logic to reverse a string, may be because we dont explore the in-built functions of the language.

char [] strArray = TextBox1.Text.ToCharArray();
Array.Reverse( strArray );
string ReverseString = new string( strArray );
Label1.Text = ReverseString;

Create CLR Stored Procedure

With the latest version of SQL Server 2005, we have the the ability to write CLR from any .Net language.

Lets dig into more details:
I have started leaning C#, so let me show you how to write this code in C#. Please bare with me on the logic :)

Step:
1. Start Visual Studio 2005
2. Add new file
3. Select Class with C#
4. Mark the name as DemoProcCls.cs and write the below lines of code.

using System.Data.SqlServer;
using System.Data.SqlTypes;
public class DemoProcCls
{
public static void DemoProc()
{
SqlPipe sqlPipe = SqlContext.GetPipe();
sqlPipe.Send("Hello World");
}
}

i) Compile the code into assembly
You need to find out the SQL Server path of "sqlaccess.dll".

csc /target:library D:\DemoProcCls.cs /r:"sqlaccess.dll"

ii) Load the above created assembly in SQL with the use of CREATE PROCEDURE
create procedure SampleDemoProc
as external name DemoProcCls.DemoProcCls.DemoProc

and execute the stored procedure as

exec SampleDemoProc

Monday, December 29, 2008

Table Size in SQL Server

SELECT
CASE WHEN (GROUPING(sob.name)=1) THEN 'Total'
ELSE ISNULL(sob.name, 'unknown') END AS 'Table',
SUM(sys.length) AS Byte_Length
FROM sysobjects sob, syscolumns sys
WHERE sob.xtype='u'
AND sys.id=sob.id
GROUP BY sob.name
WITH CUBE

Identity Key columns in SQL Server

Use the below query to get all identity columns in the database.

SELECT SCHEMA_NAME(schema_id) AS schema_name,
t.name AS table_name,
c.name AS column_name
FROM sys.tables AS t
JOIN sys.identity_columns c ON t.OBJECT_ID = c.OBJECT_ID
ORDER BY schema_name, table_name;

NUnit

NUnit is an automated unit testing framework for .NET

NUnit is free to use with your .NET projects.

NUnit is ported from another product called JUnit, which is a unit testing framework for Java applications.

NUnit provides a class library which includes some classes and methods to help you write test scripts.

NUnit provides graphical user interface application to execute all the test scripts and show the result as a success/failure report (instead of message boxes from the test script).

NUnit is the most popular unit testing framework for .net applications.

NUnit does not create any test scripts by itself. You have to write test scripts by yourself, but NUnit allows you to use it's tools and classes to make the unit testing easier.

NUnit is an open source product. You can get this tool along with source code and modify the source code if required for your specific needs. However, 99% of the programmers do not mess with the source code. Instead, you can download only the executable and class library and implement unit test scripts for your application.

Now Microsoft offers a team collaboration system called 'Visual Studio Team System' (VSTS). This tool includes a unit testing framework also. So, eventually most of the developers may switch to VSTS instead of NUnit. However, NUnit will continue to exist because it is free and easy to use.

Microsoft Visual Studio 2010

Microsoft Visual Studio 2010 and the .NET Framework 4.0 are the next generation development tools and platform for Windows Vista, the 2007 Office System, and the Web.



Visual Studio 2010 and the .NET Framework 4.0 mark the next generation of developer tools from Microsoft. Designed to address the latest needs of developers, Visual Studio delivers key innovations in the following pillars:

Democratizing Application Lifecycle Management
Application Lifecycle Management (ALM) crosses many roles within an organization and traditionally not every one of the roles has been an equal player in the process. Visual Studio Team System 2010 continues to build the platform for functional equality and shared commitment across an organization’s ALM process.

Enabling emerging trends
Every year the industry develops new technologies and new trends. With Visual Studio 2010 and .NET Framework 4.0, Microsoft delivers tooling and framework support for the latest innovations in application architecture, development and deployment.

Inspiring developer delight
Ever since the first release of Visual Studio, Microsoft has set the bar for developer productivity and flexibility. Visual Studio 2010 continues to deliver on the core developer experience by significantly improving upon it for roles involved with the software development process. .NET Framework 4.0 contains numerous improvements that make it easier to develop powerful and compelling applications.

Riding the next generation platform wave
Microsoft continues to invest in the market leading operating system, productivity application and server platforms to deliver increased customer value in these offerings. With Visual Studio 2010 and .NET Framework 4.0 customers will have the tooling support and the platform support needed to create amazing solutions around these technologies.


Check out the below link for more information
http://www.microsoft.com/downloads/details.aspx?FamilyId=922B4655-93D0-4476-BDA4-94CF5F8D4814&displaylang=en

http://www.microsoft.com/visualstudio/products/2010/default.mspx

ASP.Net 2010

Next generation of developer tool from Microsoft is available now (CTP version)

Some Links for ASP.Net 2010(4.0) explaining about the features of .NET Framework 4.0
http://msdn.microsoft.com/en-us/vs2008/products/cc948977.aspx

http://www.codeproject.com/KB/cs/concept_ide.aspx

http://blogs.msdn.com/somasegar/archive/2008/09/29/what-s-next-for-visual-studio-and-net-fx.aspx

You can also download the Beta Version of ASP.Net 2010(v4.0).

https://connect.microsoft.com/VisualStudio/content/content.aspx?ContentID=9790

Yet to lay my hands on it. But Can't wait.

Cloud Computing

Cloud computing is a computing paradigm in which tasks are assigned to a combination of connections, software and services accessed over a network. This network of servers and connections is collectively known as "the cloud." Computing at the scale of the cloud allows users to access supercomputer-level power. Using a thin client or other access point, like an iPhone, BlackBerry or laptop, users can reach into the cloud for resources as they need them.

check out the below link
http://searchenterprisedesktop.techtarget.com/sDefinition/0,,sid192_gci1287881,00.html#

Avoid Postback

I had to show an alert on a button click,but when ever i "OK" it always postsback.

To avoid such a thing simply we can use HTML Control.

have the following code in code-behind window.

Button.Attributes.Add("onclick","alert('Are You Sure ??');return false;");

This will prevent postback....

Debug Java Script

Are you in need of debugging the java script code and since VS dont support this by default, this could be done by using multiple alerts at the place where we need to know the obj values... But this is tricky to handle...

So Go for debugger; option which enables your browser to ask for debugging Javascript coding And this debugging could be done with editors of VS (From VS 2003).

example -
function(value)
{
debugger;
var test;
if(value==1)
return true;
else
return false;
}

Note: For this ur browser has to be enabled for script debugging.
Goto Tools-> Options -> Internet Options[Advanced Tab].Ensure Disable script debugging options are unselected.

State Management Interview Questions

What is ViewState?
ViewState allows the state of objects (serializable) to be stored in a hidden field on the page. ViewState is transported to the client and back to the server, and is not stored on the server or any other external source. ViewState is used the retain the state of server-side objects between postabacks.

What is the lifespan for items stored in ViewState?
Item stored in ViewState exist for the life of the current page. This includes postbacks (to the same page).

What does the "EnableViewState" property do? Why would I want it on or off?
It allows the page to save the users input on a form across postbacks. It saves the server-side values for a given control into ViewState, which is stored as a hidden value on the page before sending the page to the clients browser. When the page is posted back to the server the server control is recreated with the state stored in viewstate.

What are the different types of Session state management options available with ASP.NET?
ASP.NET provides In-Process and Out-of-Process state management. In-Process stores the session in memory on the web server. This requires the a "sticky-server" (or no load-balancing) so that the user is always reconnected to the same web server. Out-of-Process Session state management stores data in an external data source. The external data source may be either a SQL Server or a State Server service. Out-of-Process state management requires that all objects stored in session are serializable.

Tracing in ASP.NET

ASP.NET tracing enables you to view diagnostic information about a single request for an ASP.NET page. ASP.NET tracing enables you to follow a page's execution path, display diagnostic information at run time, and debug your application. ASP.NET tracing can be integrated with system-level tracing to provide multiple levels of tracing output in distributed and multi-tier applications.

ASP.NET tracing offers the following features:

Debugging statments You can write debug statements in your code without having to remove them from your application when it is deployed to production servers. You can also write variables or structures in a page and trace through the execution path of your page or application.

Integrated tracing functionality You can route messages emitted by the System.Diagnostics..::.Trace class to ASP.NET tracing output, and route messages emitted by ASP.NET tracing to System.Diagnostics..::.Trace. You can also forward ASP.NET instrumentation events to System.Diagnostics..::.Trace. For more information, see Walkthrough: Integrating ASP.NET Tracing with System.Diagnostics Tracing.

Programmatic access to trace messages You can access and manipulate trace messages from your code for finer control over the format of trace messages or for additional processing that you require.

Application-level tracing The application-level tracing option lets you view the most recent tracing data available without restarting a tracing session and without increasing the amount of tracing data that the server must store. The most recent tracing data is displayed, and older tracing data is discarded.

log into the below link for more information:
http://msdn.microsoft.com/en-us/library/bb386420.aspx

Thursday, December 11, 2008

Ajax examples

Ajax allows for rich-internet applications that mimic the responsiveness and complex user interfaces typically associated with desktop applications. Moving applications to the web browser opens many possibilities, including the ability to save user data, connecting with other users for collaboration and sharing, and making deployment and using the application easier since web browsers are standard-issue with most computers regardless of operating system.

If you’re interested in expanding your understanding of Ajax techniques and practices, check out these 25 hand-picked Ajax articles and tutorials that outline various methods and concepts involved in the development of Ajax-based applications.

Please check out below link to get the 25 hand-picked Ajax articles and tutorials

http://sixrevisions.com/ajax/ajax_techniques/

ASP.NET Caching Part 2

Data Caching
So we know that we can cache an entire page, or a fragment of a page by caching down to the user control level. Wouldn’t it be great if we could cache down to the object level? The good news is you can with ASP.NET Data caching.

The cache consists of a dictionary collection that is private to each application in memory. To insert items in the cache simply provide the collection with a unique name:

Cache["USER_id"] = myObject;

Retrieving the object form the cache:

myObj = (MyObj)Cache["USER_id"];

It is a good time to point out that you should always remember to check for null, and be sure to caste to your datatype.

Cache Configuration
If you are familiar with how caching worked in ASP.NET 1.0, you realize that managing all the cache directions for all your pages could potentially get out of hand. ASP.NET 2.0 introduces Cache Profiles that helps you centrally manage your cache. Cache settings can be inherited by your pages, and overridden if required by using the OutputCache directive.

The page directive looks pretty much the same, expect this time it references a cache profile that you defined in your web.config file.

<%@ Page Language=”C#” %>
<%@ OutputCache CacheProfile=”testCacheProfile” VaryByParam=”none” %>













So each and every page that references the ‘testCacheProfile’ can be centrally managed in the web.config, this means that any changes to the cache settings in the web.config file will be automatically changed on all your referenced pages.

ASP.NET Caching Part 1

There are various kinds of cachings available in ASP.NET. In fact i would say Caching is very cool feature in .net to improve application performance.

Different kinds of caching that you can use in your web applications


Output Caching
Performance is improved in an ASP.NET application by caching the rendered markup and serving the cached version of the markup until the cache expires. For example, if you have a page that displays user information from a database, caching will help improve performance by serving the page from memory instead of making a connection to the database on each page request.

You can cache a page by using the OutputCache API or simply by using the @OutputCache directive.

<%@ Page Language=”C#” %>
<%@ OutputCache Duration=”30” VaryByParam=”none” %>

The above cache directive will cache the page for 30 minutes.

So output caching is great for when you want to cache an entire page.


Fragment Caching
In many situations caching the entire page just isn’t going to cut it, for some reason or another you require specific sections of the page to display live information. One way to improve performance is to analyze your page and identify objects that require a substantial overhead to run. You can build a list of these objects that are expensive to run, and then cache them for a period of time using fragment caching.

For example, say your page default.aspx consists of three user controls. After looking over the code, you identified that you can cache one of them. You can simply add the caching directive to the top of the user control:

<%@ Control %>
<%@ OutputCache Duration=”15” VaryByParam=”none” %>

Now keep in mind that the actual page that contains the control is not cached, only the user control. This means that the default.aspx page will be rendered each and every page request, but the user control is only ‘run’ every 15 minutes.



Keep watching for more information

Wednesday, December 10, 2008

WCF Fundamentals

As the Services need to communicate with clients by sending and receiving messages, naturally in WCF consists of three main concepts:
• Services: Programs that respond to clients. They can send or receive messages.
• Clients: Programs that ask for a service. They can send or receive messages.
• Intermediaries: Programs that works as link between services and clients, for example, they can work as a firewall or can rout messages.
As a developer you will be writing the clients and services. WCF generally takes care of the intermediaries and the messaging. A service can have more than one client and each service can be a client of another service. As you can see WCF is mainly about communication between services provided over the web, you will come across some important concepts like Channels, Bindings, Contracts, Behaviors, Addresses and Endpoints time and again.
Windows Communication Foundation has five-layer architecture. Developers with different skills generally work on different layers. These layers top to down are:
• Application Layer: the application is located in the topmost layer.
• Contracts Layer: below the application layer is the contracts layer where the data and message contracts and bindings and policies are present. In this level services describe themselves to clients.
• Runtime Layer: this layer loads the services and defines the Behaviors.
• Messaging Layer: as the name suggests this layer is responsible for communication between services and deals with different channels and encoding.
• Hosting Layer: this layer contains the host services. You can host a service in two ways.
? You can host a service in Internet Information Services (IIS). This way your services are started and stopped automatically.
? You can create executable files (.EXE) for services and start and stop them manually by writing codes.
There are three programming approaches in Windows Communication Foundation:
• Imperative: You use programming codes in different languages to accomplish a task.
• Configuration Based: You use configuration files to do things.
• Declarative: You use attributes to declare something.
Generally, contracts and behaviors are declared using attributes, configure endpoints, security and some other settings in configuration files and service methods logic are implemented in codes. There are typed services and untyped services. In typed services normal objects and data types are passed and returned, and in untyped services the messages are passed and returned in the lower level.
If you are working with Visual Studio 2005, then you will have to install Visual Studio 2005 xtensions for .NET Framework 3.0 WCF and WPF. After installing this package, you will have new project templates in your Visual Studio to start developing for Windows Communication Foundation.
And if you are working with Visual Studio 2008, you get the new templates for WCF services, in the create web site dialog box.

ASP.Net Interview Questions - Part 7

Q1. Explain the differences between Server-side and Client-side code?
Ans. Server side code will execute at server (where the website is hosted) end, & all the business logic will execute at server end where as client side code will execute at client side (usually written in javascript, vbscript, jscript) at browser end.

Q2. What type of code (server or client) is found in a Code-Behind class?
Ans. Server side code.

Q3. How to make sure that value is entered in an asp:Textbox control?
Ans. Use a RequiredFieldValidator control.

Q4. Which property of a validation control is used to associate it with a server control on that page?
Ans. ControlToValidate property.

Q5. How would you implement inheritance using VB.NET & C#?
Ans. C# Derived Class : Baseclass
VB.NEt : Derived Class Inherits Baseclass

Q6. Which method is invoked on the DataAdapter control to load the generated dataset with data?
Ans. Fill() method.

Q7. What method is used to explicitly kill a user's session?
Ans. Session.Abandon()

Q8. What property within the asp:gridview control is changed to bind columns manually?
Ans. Autogenerated columns is set to false

Q9. Which method is used to redirect the user to another page without performing a round trip to the client?
Ans. Server.Transfer method.

Q10. How do we use different versions of private assemblies in same application without re-build?
Ans.Inside the Assemblyinfo.cs or Assemblyinfo.vb file, we need to specify assembly version.
assembly: AssemblyVersion

ASP.Net Interview Questions - Part 6

Qs. What is shared and private assembly ?
Answer Shared assemblies are accessed by more than one application and they are stored in GAC. private assemblies are accessed
by only one application and they are stored in application directory and one of its subdirectory.

Qs. What is strong name and which tool is used for this ?
Answer If you want to design an assembly which is used by more than one application then that assembly should be assigned
a strong name. sn.exe is used to generate a strong name.(Note:Once the strongname is given to an assembly it no longer remians private)
Answer Strong Name is to be assigned to shared assembly. when more then one application is going to use that dll/assembly,
that assembly has to assign a strong name and has to be place in GAC(Global Assembly Cache).

Qs. Difference between and
Answer u can declare ur database connection in connection string and u can declare all ur application settings in appsettings like ur service url etc.
In you can store any key and value pairs where as in the you can have only the name and connectionstring attribute.
is used before connection string we use it to set the applicstion setting so that program run successfully,but
is used to make the or establish the connection.

Qs. Can two application one using private assembly and other using Shared assembly be stated as a side-by-side executables?
Answer Side-by-side execution is the ability to run multiple versions of an application or component on the same computer.
You can have multiple versions of the common language runtime, and multiple versions of applications and components that use a version of the runtime, on the same computer at the same time.
Since versioning is only applied to shared assemblies, and not to private assemblies, two application one using private assembly and one using shared assembly cannot be stated as side-by-side executables.

ASP.Net Interview Questions - Part 5

Can you give an example of what might be best suited to place in the
Application_Start and Session_Start subroutines?

Ans :The Application_Start event is guaranteed to occur only once throughout the lifetime of the application. It’s a good place to initialize global variables. For example, you might want to retrieve a list of products from a database table and place the list in application state or the Cache object. SessionStateModule exposes both Session_Start and Session_End events..


What are ASP.NET Web Forms? How is this technology different than what is
available though ASP?

Ans :Web Forms are the heart and soul of ASP.NET. Web Forms are the User Interface (UI) elements that give your Web applications their look and feel. Web Forms are similar to Windows Forms in that they provide properties, methods, and events for the controls that are placed onto them. However, these UI elements render themselves in the appropriate markup language required by the request, e.g. HTML. If you use Microsoft Visual Studio .NET, you will also get the familiar drag-and-drop interface used to create your UI for your Web application..


How does VB.NET/C# achieve polymorphism?

Ans :By using Abstract classes/functions..


Can you explain what inheritance is and an example of when you might use it?

Ans :Inheritance is a fundamental feature of an object oriented system and it is simply the ability to inherit data and functionality from a parent object. Rather than developing new objects from scratch, new code can be based on the work of other programmers, adding only new features that are needed..


What’s an assembly?

Ans :Assemblies are the building blocks of .NET Framework applications; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the common language runtime with the information it needs to be aware of type implementations. To the runtime, a type does not exist outside the context of an assembly..


Describe the difference between inline and code behind - which is best in a
loosely coupled solution?

Ans :ASP.NET supports two modes of page development: Page logic code that is written inside "script runat=server" blocks within an .aspx file and dynamically compiled the first time the page is requested on the server. Page logic code that is written within an external class that is compiled prior to deployment on a server and linked "behind" the .aspx file at run time..


Explain what a diffgram is, and a good use for one?

Ans :A DiffGram is an XML format that is used to identify current and original versions of data elements. The DataSet uses the DiffGram format to load and persist its contents, and to serialize its contents for transport across a network connection. When a DataSet is written as a DiffGram, it populates the DiffGram with all the necessary information to accurately recreate the contents, though not the schema, of the DataSet, including column values from both the Original and Current row versions, row error information, and row order..


Where would you use an iHTTPModule, and what are the limitations of
anyapproach you might take in implementing one?

Ans :One of ASP.NET’s most useful features is the extensibility of the HTTP pipeline, the path that data takes between client and server. You can use them to extend your ASP.NET applications by adding pre- and post-processing to each HTTP request coming into your application. For example, if you wanted custom authentication facilities for your application, the best technique would be to intercept the request when it comes in and process the request in a
custom HTTP module..

ASP.Net Interview Questions - Part 4

What is delay signing?

Ans :Delay signing allows you to place a shared assembly in the GAC by signing the assembly with just the public key. This allows the assembly to be signed with the private key at a later stage, when the development process is complete and the component or assembly is ready to be deployed. This process enables developers to work with shared assemblies as if they were strongly named, and it secures the private key of the signature from being accessed at different stages of development..


What’s the difference between code-based security and role-based security?
Which one is better?

Ans :Code security is the approach of using permissions and permission sets for a given code to run. The admin, for example, can disable running executables off the Internet or restrict access to corporate database to only few applications. Role-based security most of the time involves the code running with the privileges of the current user. This way the code cannot supposedly do more harm than mess up a single user account. There’s no better, or 100%
thumbs-up approach, depending on the nature of deployment, both code-based and role-based security could be implemented to an extent..


How can you work with permissions from your .NET application?

Ans :You can request permission to do something and you can demand certain permissions from other apps. You can also refuse permissions so that your app is not inadvertently used to destroy some data..


How can C# app request minimum permissions?

Ans :Using System.Security.Permissions; [assembly:FileDialogPermissionAttribute(SecurityAction.RequestMinimum, Unrestricted=true)].


What’s a code group?

Ans :A code group is a set of assemblies that share a security context..


What’s the difference between authentication and authorization?

Ans :Authentication happens first. You verify user’s identity based on credentials. Authorization is making sure the user only gets access to the resources he has credentials for..


What are the authentication modes in ASP.NET?

Ans :None, Windows, Forms and Passport..


Are the actual permissions for the application defined at run-time or compiletime?

Ans :The CLR computes actual permissions at runtime based on code group membership and the calling chain of the code..


Explain the differences between Server-side and Client-side code?

Ans :Server side scripting means that all the script will be executed by the server and interpreted as needed. ASP doesn’t have some of the functionality like sockets, uploading, etc. For these you have to make a custom component usually in VB or VC++. Client side scripting means that the script will be executed immediately in the browser such as form field validation, clock, email validation, etc. Client side scripting is usually done in VBScript or JavaScript. Download time, browser compatibility, and visible code - since JavaScript and VBScript code is included in the HTML page, then anyone can see the code by viewing the page source. Also a possible security hazards for the client computer..


Should validation (did the user enter a real date) occur server-side or client-side? Why?

Ans :Client-side validation because there is no need to request a server side date when you could obtain a date from the client machine..


What does the "EnableViewState" property do? Why would I want it on or off?

Ans :Enable ViewState turns on the automatic state management feature that enables server controls to re-populate their values on a round trip without requiring you to write any code. This feature is not free however, since the state of a control is passed to and from the server in a hidden form field. You should be aware of when ViewState is helping you and when it is not. For example, if you are binding a control to data on every round trip (as in the datagrid example in tip #4), then you do not need the control to maintain it’s view state, since you will wipe out any re-populated data in any case. ViewState is enabled for all server controls by default. To disable it, set the EnableViewState property of the control to false..

ASP.Net Interview Questions - Part 3

How do you display an editable drop-down list?

Ans : Displaying a drop-down list requires a template column in the grid. Typically, the ItemTemplate contains a control such as a data-bound Label control to show the current value of a field in the record. You then add a drop-down list to the EditItemTemplate. In Visual Studio, you can add a template column in the Property builder for the grid, and then use standard template editing to remove the default TextBox control from the EditItemTemplate
and drag a DropDownList control into it instead. Alternatively, you can add the template column in HTML view. After you have created the template column with the drop-down list in it, there are two tasks. The first is to populate the list. The second is to preselect the appropriate item in the list — for example, if a book’s genre is set to “fiction,” when the drop-down list displays, you often want “fiction” to be preselected.


How do you check whether the row data has been changed?

Ans :The definitive way to determine whether a row has been dirtied is to handle the changed event for the controls in a row. For example, if your grid row contains a TextBox control, you can respond to the control’s TextChanged event. Similarly, for check boxes, you can respond to a CheckedChanged event. In the handler for these events, you maintain a list of the rows to be
updated. Generally, the best strategy is to track the primary keys of the affected rows. For example, you can maintain an ArrayList object that contains the primary keys of the rows to update..


What do you know about .NET assemblies?

Ans: Assemblies are the smallest units of versioning and deployment in the .NET application. Assemblies are also the building blocks for programs such as Web services, Windows services, serviced components, and .NET remoting applications.


What’s the difference between private and shared assembly?

Ans : Private assembly is used inside an application only and does not have to be identified by a strong name. Shared assembly can be used by multiple applications and has to have a strong name..


What’s a strong name?
Ans :A strong name includes the name of the assembly, version number, culture identity, and a public key token..


How can you tell the application to look for assemblies at the locations other than its own install?

Ans :Use the directive in the XML .config file for a given application.
should do the trick. Or you can add additional search paths in the Properties box of the deployed application..


How can you debug failed assembly binds?

Ans :Use the Assembly Binding Log Viewer (fuslogvw.exe) to find out the paths searched..


Where are shared assemblies stored?

Ans :Global Assembly Cache..


How can you create a strong name for a .NET assembly?

Ans :With the help of Strong Name tool (sn.exe)..


Where’s global assembly cache located on the system?

Ans :Usually C:\winnt\assembly or C:\windows\assembly..


Can you have two files with the same file name in GAC?

Ans :GAC is a very special folder, and while normally you would not be able to place two files with the same name into a Windows folder, GAC differentiates by version number as well, so it’s possible for MyApp.dll and MyApp.dll to co-exist in GAC if the first one is version 1.0.0.0 and the second one is 1.1.0.0..

ASP.Net Interview Questions - Part 2

Where do you store the information about the user’s locale?

Ans :System.Web.UI.Page.Culture.


What’s the difference between Codebehind="MyCode.aspx.cs" and
Src="MyCode.aspx.cs"?

Ans : CodeBehind is relevant to Visual Studio.NET only.


What’s a bubbled event?

Ans :When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button,row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents.. Suppose you want a certain ASP.NET function executed on MouseOver over a
certain button.


Where do you add an event handler?

Ans :It’s the Attributesproperty, the Add function inside that property. So
btnSubmit.Attributes.Add("onMouseOver","someClientCode();") A simple”Javascript:ClientCode();” in the button control of the .aspx page will attach the handler (javascript function)to the onmouseover event..


What data type does the RangeValidator control support?

Ans :Integer,String and Date..


Where would you use an iHTTPModule, and what are the limitations of any
approach you might take in implementing one?

Ans :One of ASP.NET’s most useful features is the extensibility of the HTTP pipeline, the path that data takes between client and server. You can use them to extend your ASP.NET applications by adding pre- and post-processing to each HTTP request coming into your application. For example, if you wanted custom authentication facilities for your application, the best technique would be to intercept the request when it comes in and process the request in a
custom HTTP module..


Explain what a diffgram is and a good use for one?

Ans :A DiffGram is an XML format that is used to identify current and original versions of data elements. The DataSet uses the DiffGram format to load and persist its contents, and to serialize its contents for transport across a network connection. When a DataSet is written as a DiffGram, it populates the DiffGram with all the necessary information to accurately recreate the contents, though not the schema, of the DataSet, including column values from both the Original and Current row versions, row error information, and row order..


What is datagrid?

Ans :The DataGrid Web server control is a powerful tool for displaying information from a data source. It is easy to use; you can display editable data in a professional-looking grid by setting only a few properties. At the same time, the grid has a sophisticated object model that provides you with great flexibility in how you display the data..


What’s the difference between the System.Web.UI.WebControls.DataGrid and and
System.Windows.Forms.DataGrid?

Ans :The Web UI control does not inherently support master-detail data structures. As with other Web server controls, it does not support two-way data binding. If you want to update data, you must write code to do this yourself. You can only edit one row at a time. It does not
inherently support sorting, although it raises events you can handle in order to sort the grid contents. You can bind the Web Forms DataGrid to any object that supports the IEnumerable interface. The Web Forms DataGrid control supports paging. It is easy to customize the appearance and layout of the Web Forms DataGrid control as compared to the Windows Forms one.


How do you customize the column content inside the datagrid?

Ans : If you want to customize the content of a column, make the column a template column. Template columns work like item templates in the DataList or Repeater control, except that you are defining the layout of a column rather than a row.


How do you apply specific formatting to the data inside the cells?

Ans :You cannot specify formatting for columns generated when the grid’s
AutoGenerateColumns property is set to true, only for bound or template columns. To format, set the column’s DataFormatString property to a string-formatting expression suitable for the data type of the data you are formatting.


How do you hide the columns?

Ans :One way to have columns appear dynamically is to create them at design time, and then to hide or show them as needed. You can do this by setting a column’s Visible property.

ASP.Net Interview Questions - Part 1

How many languages .NET is supporting now?

Ans : When .NET was introduced it came with several languages. VB.NET, C#, COBOL and Perl,etc. The site DotNet Languages. Net says 44 languages are supported..


How is .NET able to support multiple languages?

Ans : A language should comply with the Common Language Runtime standard to become a .NET language. In .NET, code is compiled to Microsoft Intermediate Language (MSIL for short). This is called as Managed Code. This Managed code is run in .NET environment. So after compilation to this IL the language is not a barrier. A code can call or use a function written in another language..


How ASP .NET different from ASP?

Ans : Scripting is separated from the HTML, Code is compiled as a DLL, and these DLLs can be executed on the server.


What is smart navigation?

Ans : The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.


What is view state?

Ans: The web is stateless. But in ASP.NET, the state of a page is maintained in the page itself automatically. How? The values are encrypted and saved in hidden controls. This is done automatically by the ASP.NET. This can be switched off / on for a single control.


How do you validate the controls in an ASP .NET page?

Ans : Using special validation controls that are meant for this. We have Range Validator, Email Validator.


Can the validation be done in the server side? Or this can be done only in the
Client side?

Ans :Client side is done by default. Server side validation is also possible. We can switch off the client side and server side can be done..


How to manage pagination in a page?

Ans :Using pagination option in DataGrid control. We have to set the number of records for a page, then it takes care of pagination by itself.


What is ADO .NET and what is difference between ADO and ADO.NET?

Ans :ADO.NET is stateless mechanism. I can treat the ADO.Net as a separate in-memory database where in I can use relationships between the tables and select insert and updates to the database. I can update the actual database as a batch..


Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process ?

Ans :inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests among other things.When an ASP.NET request is received (usually a file with .aspx extension),the ISAPI filter aspnet_isapi.dll takes care of it by passing the request tothe actual worker process aspnet_wp.exe..


What’s the difference between Response.Write() and Response.Output.Write()?

Ans :The latter one allows you to write formatted output..


What methods are fired during the page load?

Ans :Init() - when the page is instantiated, Load() - when the page is loaded into server memory, PreRender() - the brief moment before the page is displayed to the user asHTML, Unload() - when page finishes loading..


Where does the Web page belong in the .NET Framework class hierarchy?

Ans :System.Web.UI.Page

Friday, November 21, 2008

Copy in SQL Server

How to copy the tables, schema and views from one SQL Server to another?

There are multiple ways to do this.

1. "Detach Database" from one server and "Attach Database" to another server.
2. Manually script all the objects using SSMS and run the script on new server.
3. Use Wizard of SSMS.
How to copy data from one table to another table?

There are multiple ways to do this.

INSERT INTO SELECT

This method is used when table is already created in the database earlier and data is to be inserted into this table from another table. If columns listed in insert clause and select clause are same, they are not required to list them.

SELECT INTO

This method is used when table is not created earlier and needs to be created when data from one table is to be inserted into newly created table from another table. New table is created with same data types as selected columns.

Multiple Insert in SQL Server

One ofthe v ery good feature of SQL Server 2008 is to insert multiple records at one using single INSERT statements.

INSERT INTO dbo.Departments
VALUES (1, 'Human Resources', 'Maryam'),(2, 'Sales', 'Biju'),
(3, 'Finance', 'Gilly'),(4, 'Purchasing', 'Barbera'),
(5, 'Manufacturing', 'Screwer');

Database connection in VB.NET

Many of the beginners doesnot have the basic idea of how to establish a database connection with Visual Studio Asp.net and SQL server.
Here is a small description of it.

(All the code is written in VB.Net)

1. When connecting to a database, first of all, you need two variables, one for connection and another for the sql commands.

Dim con As New Data.SqlClient.SqlConnection()
Dim cmd As New Data.SqlClient.SqlCommand()

2. You need a "connection" between design page and database

con.ConnectionString = "Data Source=;Initial Catalog=;Integrated Security=True"

Note: Integrated Security is used when "Windows Authentication" is used. If you use server authentication, then following code will be used

con.ConnectionString = "Data Source=;Initial Catalog=;uid=;pwd="

3. You need a command text

cmd.CommandText = ""

4. Establish a relation between command and the connection

cmd.Connection = con

5. Open the connection

con.open()

6. The actual operation is done in this step.

cmd.ExecuteNonQuery()

7. Close the connection

con.Close()


So thats it !!! You have done...
Here is an example of the above explanation :


Dim con As New Data.SqlClient.SqlConnection()
Dim cmd As New Data.SqlClient.SqlCommand()
con.ConnectionString = "Data Source=VJ\SQLEXPRESS;Initial Catalog=TestDB;Integrated Security=True"
cmd.CommandText = "INSERT INTO tblAddress(UName,Street,City) VALUES(@user,@street,@city)"
con.Open()
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()

Differences Between Properties and Indexers in C#

Properties:

1)Identified by its name.
2)Accessed through a simple name or a member access.
3)Can be a static or an instance member.
4)A get accessor of a property has no parameters.
5)A set accessor of a property contains the implicit value parameter.

Indexers:
1)Identified by its signature.
2)Accessed through an element access.
3)Must be an instance member.
4)A get accessor of an indexer has the same formal parameter list as the indexer.
5)A set accessor of an indexer has the same formal parameter list as the indexer, in addition to the value parameter.

config files in .Net

Web.config:--Basically this file is use for web setting or we can say web.config file contains setting to a web application.

Machine.config:--Settings to a computer and that help to configure all application into same machine.

Example:--
In a machine it can be more then one web application so each application will have one or more web.config files depend on configuration level of folders but in that system there will be one machine.config file.

Overview of ASP.NET 3.5

ASP.NET has for long been a popular web application development platform. ASP.NET 2.0 added a lot of new features compared to its earlier counterpart, i.e., ASP.NET 1.1. With ASP.NET 3.5, you have even more features. This article will present the new features that have been added to ASP.NET and Visual Studio 2008.


In ASP.NET 3.5, a new tool has been introduced called the ASP.NET Merge Tool. You can use this tool for merging pre-compiled assemblies. No, this is not all. There isa lot of other exciting features and we will explore each of them as we progress through this article.

The most significant improvements in ASP.NET are:

* Integrated Ajax Support
* New Data Controls (ListView and DataPager)
* The LinqDataSource Control

Visual Studio 2008 has also included some features for an improved web application development experience. Here is the list of such improvements:


* Support for LINQ
* IntelliSense for JavaScript and ASP.NET Ajax
* Improved Design time experience

Please refer to below link for detailed explantion
http://aspnet.4guysfromrolla.com/articles/112107-1.aspx

Indexes in SQL Server

One of the common task in day-to-day life to resolve the performance issues with teh SQL queries. When there is a perfrmance issue with a Query that first thing that we do is Look for the QEP (Query Execution Plan). In this if any table is going for Full table scan then we want to know if there are indexes on that table or not. So below is the piece of code which can be used to list out all the indexes.

select name from sysindexes where id=object_id('Employees')

rename Column in SQL Server

The following sample code demonstrates how to rename a column in SQL server using the stored procedure

EXEC sp_rename
@objname = '[TableName].OldColumnName',
@newname = 'NewColumnName',
@objtype = 'COLUMN'

This stored procedure can also be used to rename the tables.

Computer Jokes

Struct professional
{
double styles;
Short skirts;
Void knowledge;
Char ununderstand;
}


Struct married
{
double weight;
Short tempered;
void speech;
Char unstable;
}


Struct engaged
{
double timeonphone;
Short attentiononwork;
Long boast;
Void understanding;
}


Struct newly_married_ females
{
double dinnerinvitation;
Short timeatwork;
Long lunchbreak;
Void bankbalance;
}


Struct husband_wife_ professionals
{
double income;
Short tempered;
Long notimesee_eachother;
Void life;
Char money_making;
}


Struct beautiful_city_ girl
{
double boyfriends;
Short affairs;
Long stories;
Void greymatter;
Char dating;
}


Struct old_lady
{
Short memory;
Long sighs ;
Void attention_from_ men;
}

Clear all Textboxes

In Our applications in most of the cases we have to clear all text boxes (when Cancel or Reset button is clicked)
This code is to clear all text boxes in the form .

Use This code in Button click event
public void imgcancel_Click(object sender, ImageClickEventArgs e) {
FindControl(Form.Controls);
}

'Find Control Method Definition
public static void FindControl(ControlCollection ChildCtrls)
{
foreach (Control Ctrl in ChildCtrls)
{
if (Ctrl is TextBox)
((TextBox)Ctrl).Text = "";
else
FindControl(Ctrl.Controls);
}
}

Saturday, October 25, 2008

IntelliSense in SQL Server 2008

Microsoft has finally released a SQL Server product that includes IntelliSense for writing TSQL statements. In this article, Tim Chapman shows the ins and outs of using IntelliSense in SQL Server 2008.

If you are used to working in the Microsoft Development Environment, you've likely grown accustomed to using IntelliSense, a feature which reads internal metadata and provides a list of available objects and properties while you are developing.

However, this feature has yet to be available to the TSQL language inside the SQL Server Management Studio. I am happy, though, to say that SQL Server 2008 finally includes TSQL IntelliSense, which provides a listing of available objects to use in SELECT statements, DML statements, and stored procedure calls, along with numerous other operations.

Check out the below link
http://www.zdnetasia.com/techguide/storage/0,39045058,62047009,00.htm

C# Syntax in SQL Server 2008

One Major advantage with Microsoft is, it always tries make life easier. See if you are C# developer and want to join SQL team then its pretty easy.

SET @i += 5

Look at the above code, it's C# syntax on incremeting the variables.

Its kool.....

In-line Variable assignment in SQL Server 2008

In SQL Server 2008, there is one feature called In-line variable assignment. Before i get into the details lets lets look at the below code.


>>>In SQL Server 2005
DECLARE @MyEmpNumber INT
SET @MyEmpNumber = 24
SELECT @MyEmpNumber AS EmpNumber
GO
>>>In SQL Server 2008
DECLARE @MyEmpNumber INT = 24
SELECT @MyEmpNumber AS EmpNumber
GO

In 2005 we can't assign the value at the variable declaration, where in 2008 you can do. This will reduce lot of code in T-SQL.

Njoy with this new feature.

XML Features in SQL Server 2008

Microsoft introduced XML-related capabilities in Microsoft SQL Server 2000 with the FOR XML and OPENXML Transact-SQL keywords, which enabled developers to write Transact-SQL code to retrieve a query result as a stream of XML and to shred an XML document into a rowset. SQL Server 2005 extended these XML capabilities significantly with the introduction of a native xml data type that supports XSD schema validation, XQuery-based operations, and XML indexing. SQL Server 2008 builds on the XML capabilities of previous releases and provides enhancements to meet the challenges that customers have faced when storing and manipulating XML data in the database.

Check out the below link for more information
http://download.microsoft.com/download/a/c/d/acd8e043-d69b-4f09-bc9e-4168b65aaa71/WhatsNewSQL2008XML.doc

Saturday, October 4, 2008

Pass Parameters in ASP.NET

I'm trying to pass information between pages. I'm trying to avoid using
QueryString and Session variables. so what is the way to pass the parameters from one page to another using Server.Transfer???

Can i use context or viewstate? which is better??

This is common question in various forums. My answer is

You can't send viewstate between pages. context items are sent as part of the server.transfer. After the server.transfer, context items are disposed.

COUNT Group Function

Returns the number of items in a group. COUNT_BIG works like the COUNT function. The only difference between the two functions is their return values. COUNT_BIG always returns a bigint data type value. COUNT always returns an int data type value.

@@ROWCOUNT

Rowcount_big() is a function introduced in SQL Server 2000. It returns the number of affected records in the form of a bigint number.

This is same @@ROWCOUNT but the difference is interms of the output. This retuns Int and Rowcount_BIG() returns BIG Int.

RAND() Function

SQL Server has a built-in function that generates a random number, the RAND() mathematical function. The RAND math function returns a random float value from 0 through 1. It can take an optional seed parameter, which is an integer expression (tinyint, smallint or int) that gives the seed or start value.

To use it, you can simply do a simple SELECT, as follows:

SELECT RAND() AS Rand_Num

The result generated by this SELECT statement is as follows (note that your results may be different from the value shown here, hence the name random)

RandomNumber
---------------------
0.34344339282376501

Microsoft MVP Award

Oct 1st was one of the happiest days in my life. You want to know the reason



Dear Vijaya Krishna Kadiyala,

Congratulations! We are pleased to present you with the 2009 Microsoft® MVP Award! This award is given to exceptional technical community leaders who actively share their high quality, real world expertise with others.

The Microsoft MVP Award provides us the unique opportunity to celebrate and honor your significant contributions and say "Thank you for your technical leadership."

Toby Richards
General Manager
Community Support Services

Wednesday, October 1, 2008

MVC Pattern

What is MVC Pattern:

The main purpose of using MVC pattern is to decouple the GUIfrom the Data.
It also gives the ability to provide multiple views for the same data.MV pattern separates in to three important sections.

> Model: this section is specially for maintaining data.It is actually where yourbusiness logic,querying database,database connection etc.is actually implemented.

>Views: Displaying all or some portions of data,or probably different vciew of data.
View is responsible for look and feel,sorting,formatting etc.

>Controller: In ASP.NET the behind code is the controller as the evetns are hendled by that part.Controller communicates both with Model as well as with View

Saturday, September 27, 2008

Recompile in SQL Server

In next couple of posts i will explain about some very usefull stored procedures in SQL Server.

SP_RECOMPILE: SP_RECOMPILE

The sp_recompile stored procedure is used to recompile certain database objects. When you create a database object for the first time, the database object is compiled and a query plan is generated if all the dependencies are met. If you change the data in database objects, the stored procedures and triggers should be recompiled because the query plans generated for the database objects are no longer valid and new query plans should be generated.


The below example causes stored procedures that are using EMP table to be recompiled the next time they are run.

USE Pubs;
GO
EXEC sp_recompile N'HR.EMP'
GO

Primary Key in SQL Server

In next couple of posts i will explain about some very usefull stored procedures in SQL Server.

SP_PRIMARYKEY: SP_PRIMARYKEY TABLE,COLUMN1[, COLUMN2,....COLUMN(N)]

If you don’t know the syntax of primary key creation then this is the right procedure which you can use to create primary key. This stored procedure is used to apply the primary key constraint on a column or columns that is passed as a parameter.

The column1, column2, and column(n) parameters contain the column names on which you want to create the primary key constraint. A primary key can contain more than one column.

Use Pubs
GO
SP_PRIMARYKEY 'HR.EMP','empid
GO

Who are you

In next couple of posts i will explain about some very usefull stored procedures in SQL Server.

SP_WHO
The sp_who stored procedure is used to display all database users who are currently logged onto SQL Server. The stored procedure also displays the processes currently running on SQL Server.

Look at the below example to report all current users

USE master
GO
EXEC sp_who
GO

Change password in SQL Server

In next couple of posts i will explain about some very usefull stored procedures in SQL Server.

SP_PASSWORD: SP_PASSWORD OLD_PASS,NEW_PASS [, LOGIN_ID]

Your password is shared and wants to change the password then you need to use sp_password stored procedure. The sp_password stored procedure is used to modify the password of a login ID. You need to pass the old password of a login ID as a parameter to create a new password. You need to specify the old password as NULL when you modify the password of the SA login ID.

Microsoft is planning to remove this stored procedure usage in future versions and suggesting us to use “ALTER LOGIN” command.

Rename Objects in SQL Server

In next couple of posts i will explain about some very usefull stored procedures in SQL Server.

SP_RENAME: SP_RENAME OLD_NAME, NEW_NAME, TYPE_OF_OBJECT

The sp_rename stored procedure is used to modify the names of database objects or user-defined data types. In SQL Server each object is associated with Object ID. When you provide a new name for an existing database object, other database objects using the renamed object continue to refer to the renamed object.

old_name: parameter refers to the existing object name.
new_name: parameter refers to the name you want to assign.
type_of_object: parameter refers to the type of database object whose name you want to modify.

Renaming a table

USE Pubs
GO
EXEC sp_rename 'HR.Employees', 'EMP';
GO

Renaming a column

USE Pubs
GO
EXEC sp_rename 'HR.Employees.EmployeeID', 'EMPID', 'COLUMN';
GO

Constraint Information in SQL Server

In next couple of posts i will explain about some very usefull stored procedures in SQL Server.

SP_HELPCONSTRAINT: SP_HELPCONSTRAINTS [TABLE]

The sp_helpconstraint stored procedure is used to display information about the constraints created on the columns based on the input parameter. Constraint information contains type, name, delete action, update action, and status of constraints.


The below sample code displays the constraints information on Employee Table.

USE Pubs;
GO
EXEC sp_helpconstraint 'HR.Employees';
GO

Describe Index in SQL Server

In next couple of posts i will explain about some very usefull stored procedures in SQL Server.

SP_HELPINDEX: SP_HELPINDEX (TABLE)

The sp_helpindex stored procedure is used to display the indexes that are created on a table based on the input parameter. In addition to the indexes it will also display the columns which are part of the indexes.


USE Pubs;
GO
EXEC sp_helpindex N'HR.Employee';
GO

Columns in SQL Server

In next couple of posts i will explain about some very usefull stored procedures in SQL Server.

SP_COLUMNS: SP_COLUMNS OBJECT, [OWNER_NAME], [TABLE_QUALIFIER], [COLUMN_NAME], [ODBCVER]

The sp_columns stored procedure is used to display information about table columns or view columns. The procedure accepts the table or view name as a parameter.

OBJECT: This is nothing but table or view.
OWNER_NAME: Is nothing but owner of object. This is optional Parameter.
TABLE_QUALIFIER: parameter refers to the database name in which the table or view exists. This is optional Parameter.
COLUMN_NAME: parameter specifies the name of a column that you pass as a parameter whose information is to be displayed.
ODBCVER: Parameter specifies the ODBC version used.

USE Pubs
GO
EXEC sp_columns @table_name = N'Employee', @table_owner = N'HR';

Describe in SQL Server

In next couple of posts i will explain about some very usefull stored procedures in SQL Server.

SP_HELP: SP_HELP [OBJECT | USER_DEFINED_DATATYPE]

The sp_help stored procedure is used to display information about a database object that is passed as a parameter.

The parameter is optional. If you want to display all the objects with in the current database then don’t pass any parameter. If you are looking for specific objects information then pass the object name.

USE master
EXEC sp_help

The above code is used to display information about each object in Sysobjects.

User Details in SQL Server

In next couple of posts i will explain about some very usefull stored procedures in SQL Server.

SP_HELPUSER: SP_HELPUSER [NAME_OF_USER]

The sp_helpuser stored procedure is used to display the user(s) and role(s) present in a database based on the input. Name of the user is optional filed; if you pass a specific user then it displays information, such as user name, login name, group name, default database, user ID, and sid of the user. The procedure displays information about the current database user if no parameter is passed.

EXEC sp_helpuser

The above stored procedure is used to display all the users in the current database.

Rename Database

In next couple of posts i will explain about some very usefull stored procedures in SQL Server.

This stored procedure is to rename the database from old names to new name. Microsoft is planning to remove this from future releases and also suggesting to use ALTER DATABASE command to implement the similar functionality.

Let’s look at the sample example

USE MASTER;
GO
CREATE DATABASE BANK_DB;
GO
EXEC SP_RENAMEDB N'BANK_DB', N'INVESTMENT_BANK_DB';
GO
SELECT NAME, DATABASE_ID, MODIFIED_DATE
FROM SYS.DATABASES
WHERE NAME = N'INVESTMENT_BANK_DB';
GO


We are creating a Database name called BANK_DB and then later we are modifying/renaming it to INVESTMENT_BANK_DB.

Query the SYS.DATABASES table to see whether it’s modified or not.

StringBuilder in .Net

There are small small things which can improve the performance of the code. When we are dynamically constructing SQL query in .Net application we declare a string variable and append the SQL to it.

Ex:

String sSQL = null;
sSQL += "SELECT Col1,Col2,Col3";
sSQL += " FROM Table_name ";
sSQL += " WHERE Col4 = 10 ";

This is not a good approach to deal with String because String is immutable. Therefore, every time when you concatenate the new value a new instance will be made and it will make a great performance loss if concatenation will be done many times.

Lets look at the best apporach

System.Text.StringBuilder sSQL = new System.Text.StringBuilder();
sSQL.Append(" SELECT Col1,Col2,Col3 ");
sSQL.Append(" FROM Table_name ");
sSQL.Append(" WHERE Col4 = 10 ");

So from now on try to use StringBuilder.

Thursday, September 25, 2008

code Execution Time

There are so many procedures in this world which are running very slow, to find out the execution time of the stored procedure you need to put simple statement like CURRENT_TIMESTAMP at the begining and ending of the stored procedure.

DECLARE @start DATETIME, @End DATETIME
SET @start = CURRENT_TIMESTAMP

DECLARE @i INT
SET @i = 0
WHILE @i < 24000
BEGIN
SET @i = @i + 1
END
SET @End = CURRENT_TIMESTAMP
SELECT DATEDIFF(MS, @start, @End)

Credit Card validation

its pretty rare to imagine a person with out knowing the word "Credit Card", If some one is implementing a site which requires "Money Trasactions" then one should have this kind of validation in their code.

The below code is to validate the Input Credit card number.

//Namespace Referenceusing
System.Text.RegulsrExpressions
/// method to validate a credit card number

public static bool validCCNum(string num)
{
// This expression is looking for a series of numbers, which follow the pattern
// for Visa, MC, Discover and American Express. It also allows for dashes between sets of numbers

string pattern = @"^((4\d{3})|(5[1-5]\d{2})|(6011))-?\d{4}-?\d{4}-?\d{4}|3[4,7][\d\s-]{15}$";
Regex match = new Regex(pattern);
return match.IsMatch(num);

}

Nth Salary

One of the common questions in interviews is how to find out 2nd best salary or find 5th best salary etc...

There are somany ways to write this kind of query.

Let me show you some of them....

--Find 3rd highest salary

SELECT TOP 1 salary
FROM (
SELECT DISTINCT TOP 3 salary
FROM tblSalary
ORDER BY salary DESC) S
ORDER BY salary

Here in the Sub query we are trying to get the TOP 3 salaries based on the order by. In the outer query order it once again but this time it is ASC order to reverse order so that we can use "TOP 1" to get the 3rd best salary.

If we go and generilize this query to work for any kind of result then


--Find Nth highest salary
SELECT TOP 1 salary FROM (
SELECT DISTINCT TOP N salary FROM tblSalary ORDER BY salary DESC) S
ORDER BY salary

Just replace the replace the Number with "N" in the sub query. Now if you want 5th best salary just replace N with 5. Simple...

Dont try to remember...understand the logic/concept....

Wednesday, September 24, 2008

Find index on a table

Normally when there is an issue on the performance one really want to see how many indexes are defined on a table.

the simpest command to get this information is sp_helpindex where just pass the tablename as the input parameter to the procedure then it will list out all the indexes defined on that table.

Differences between ISNULL and COALESCE

I came across a question in the various SQL Server forums, about ISNULL and COALESCE usage. ISNULL and COALESCE can be used to get the same results but there are some differences.

they are
Data type determination of the resulting expression - ISNULL uses the first parameter type, COALESCE follows the CASE expression rules and returns type of value with highest precedence

Validations for ISNULL and COALESCE is also different. For example, NULL value for ISNULL is converted to int whereas for COAELSCE you have to provide a type. Ex:

ISNULL(NULL, NULL) -- is int

COALESCE(NULL, NULL) -- Will throw an error

COALESCE(CAST(NULL as int), NULL) -- it valid and returns int

and the other obvious difference is
ISNULL takes only 2 parameters whereas COALESCE takes variable number of parameters

Thursday, September 11, 2008

Large Objects in SQL Server

A very common issue for database developers in the past was how to store and utilize large binary objects such as documents and media files. The method typically used was to store the files outside of the database and just store a pointer in the database to the external file. With this method, however, when you move the file, you must also remember to update the pointer.

SQL Server 2008 handles this issue with the new FILESTREAM data type. With this data type, files can still be stored outside of the database, but the data is considered part of the database for transactional consistency. This allows for the use of common file operations while still maintaining the performance and security benefits of the database.

Framework 3.5 Service Pack 1

Microsoft .NET Framework 3.5 Service Pack 1 is a full cumulative update that contains many new features building incrementally upon .NET Framework 2.0, 3.0, 3.5, and includes cumulative servicing updates to the .NET Framework 2.0 and .NET Framework 3.0 subcomponents.


Some of the new features and improvements:

Core improvements to the CLR (common language runtime) that include better layout of .NET Framework native images, opting out of strong-name verification for fully trusted assemblies, improved application startup performance, better generated code that improves end-to-end application execution time, and opting managed code to run in ASLR (Address Space Layout Randomization) mode if supported by the operating system. Additionally, managed applications that are opened from network shares have the same behavior as native applications by running with full trust.

Performance improvements to WPF (Windows Presentation Foundation), including a faster startup time and improved performance for Bitmap effects. Additional functionality for WPF includes better support for line of business applications, native splash screen support, DirectX pixel shader support, and the new WebBrowser control.

Windows Communication Foundation now makes the DataContract Serializer easier to use by providing improved interoperability support, enhancing the debugging experience in partial trust scenarios, and extending syndication protocol support for wider usage in Web 2.0 applications.

The .NET Framework Data Provider for SQL Server (SqlClient) adds new support for file stream and sparse column capabilities in SQL Server 2008.

upgrade yourself from below link

http://www.microsoft.com/downloads/details.aspx?familyid=ab99342f-5d1a-413d-8319-81da479ab0d7&displaylang=en

C# Interview Questions

Does C# support multiple-inheritance?
No.

Who is a protected class-level variable available to?
It is available to any sub-class (a class inheriting this class).

Are private class-level variables inherited?
Yes, but they are not accessible. Although they are not visible or accessible via the class interface, they are inherited.

Describe the accessibility modifier “protected internal”.
It is available to classes that are within the same assembly and derived from the specified base class.

What’s the top .NET class that everything is derived from?
System.Object.

What does the term immutable mean?
The data value may not be changed. Note: The variable value may be changed, but the original immutable data value was discarded and a new data value was created in memory.

What’s the difference between System.String and System.Text.StringBuilder classes?
System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.

What’s the advantage of using System.Text.StringBuilder over System.String?
StringBuilder is more efficient in cases where there is a large amount of string manipulation. Strings are immutable, so each time a string is changed, a new instance in memory is created.

Can you store multiple data types in System.Array?
No.

What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements into another existing array. Both perform a shallow copy. A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array. A deep copy (which neither of these methods performs) would create a new instance of each element's object, resulting in a different, yet identacle object.

How can you sort the elements of the array in descending order?
By calling Sort() and then Reverse() methods.

What’s the .NET collection class that allows an element to be accessed using a unique key?
HashTable.

What class is underneath the SortedList class?
A sorted HashTable.

Will the finally block get executed if an exception has not occurred?­
Yes.

What’s the C# syntax to catch any possible exception?
A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.

Can multiple catch blocks be executed for a single try statement?
No. Once the proper catch block processed, control is transferred to the finally block (if there are any).

Explain the three services model commonly know as a three-tier application.
Presentation (UI), Business (logic and underlying code) and Data (from storage or other sources).

DotNetNuke

DotNetNuke is an open source web application framework ideal for creating, deploying and managing interactive web, intranet and extranet sites. DotNetNuke can support multiple portals or sites off of one install. DotNetNuke includes a multi-language localization feature which allows administrators to easily translate their projects and portals into any language.

some of the Silent Features

User-Friendly – DotNetNuke is designed to make it easy for administrators, content editors, developers, and designers to manage all aspects of their web assets. Wizards, content-sensitive help, and a well-researched user interface provide a superior user experience.

Powerful – DotNetNuke can support multiple websites from a single application installation. In dividing administrative options between host level and individual site level, DotNetNuke allows administrators to manage an unlimited number of websites – each with its own unique appearance and content.

Feature-Rich – DotNetNuke comes loaded with a set of built-in features that provide exceptional functionality. Site hosting, web design, content management, security, and membership options are all easily managed and customized through simple, browser-based tools.


Check out the below link

http://www.dotnetnuke.com/

umbraco

umbraco is an open source project with roots back to year 2000 even though it wasn't released as open source until 2004. Prior to that it was founder Niels Hartvig's home-grown weapon of choise for working as a freelancer.
Today it has grown to be among the top fifteen most popular open source .NET applications and in May 2008 we hit a milestone at 50.000 installed and active websites (double up from 25.000 in April 2007).

Check out the below link for more information..
http://www.umbraco.org/

Friday, September 5, 2008

Virtual TechDays

Microsoft products and tools give you the productivity boost to quickly address your most time-consuming development, deployment and management challenges, which helps you better connect with life outside work. Don't take our word for it, though. Join your fellow colleagues and Tech Gurus at this online event and explore Microsoft products online, from the cosy confines of your workstations.

During the event, the Technical Experts from Microsoft will deliver 40+ free, in-depth sessions on latest Microsoft technologies that help you boost your productivity. Get set to access these online interactive sessions and provide instant feedback.


Join us at Virtual TechDays and discover how Microsoft can help you get more out of life.




Visit the below link and register your-self.
http://www.connectwithlife.co.in/vtd/default.aspx

C u there....

Sunday, August 31, 2008

ASP.Net Tips

When using ADO.NET to make connections to SQL Server, always be sure you explicitly close any Connection, Recordset, or Command objects you have opened.

SQL Server Tips

Don't use the NVARCHAR or NCHAR data types unless you need to store 16-bit character (Unicode) data. They take up twice as much space as VARCHAR or CHAR data types, increasing server I/O and wasting unnecessary space in your buffer cache.

Load text file into SQL Server

Recently i came accross a situation where i have to load the text file data into SQL Server with simple code.
i had several options to do this but i went to the basics of SQL Server. i.e. There is one feature which was started from 7.0 i.e. BULK INSERT.

look at the sample data
-----------------------
jhonson,glen,glen@ge.com
nicole,kid,kid@nicole.com
chai,nee,nee@usa.com

BULK INSERT tmpStList FROM 'c:\data.txt' WITH (FIELDTERMINATOR = ',')

Thats it. Its so simple to do it

New Version of ODP.NET

Oracle just released its latest version of ODP.NET. This version, for Oracle 11g, provides enhancements and the much anticipated Instant Client and User Defined Types (UTDs). One big issue in the past when you were working with ODP.NET for your ASP.NET applications was that you had to install a tremendously large Oracle client application that took some time. Now with the instant client, you simply XCopy your client to the server you want it at. Very easy. UDTs was also another feature that allows you to pass custom types into the database and step away from the need to use numerous ref cursors.

ODP.NET includes the ASP.NET providers that you might be looking for including:

Membership Provider
Role Provider
Profile Provider
Session State Provider
Site Map Provider
Web Parts Personalization Provider
Web Event Provider
Cache Dependency Provider

You can look to download this version at http://www.oracle.com/technology/tech/windows/odpnet/index.html

Thursday, August 7, 2008

Except in SQL Server

This is basically to return all the records from one result set where there is no matching in another table. This looks very similar to “Outer join” but join does horizontally and EXCEPT does vertically.

Let’s look at the example:

SELECT EmployeeID,Name,Salary,DOJ from Employee
EXCEPT
SELECT EmployeeID,Name,Salary,DOJ from Employee_HIST

With the above query we are fetching only the records which are in Employee but not in Employee_HIST.

Intersection in SQL Server

As you know this is basically to combine multiple result sets into single to fetch the common records in multiple result sets. Inner join finds common rows horizontally, while an INTERSECT finds common rows vertically.

Let’s look at the example:

SELECT EmployeeID,Name,Salary,DOJ from Employee
INTERSECT
SELECT EmployeeID,Name,Salary,DOJ from Employee_HIST

We are combining the results from Employee and Employee_HIST table. When you use INTERSECT operator it will give you the common records from both the tables meaning the records that are duplicated in both the tables.

Union in SQL Server

As you know this is basically to combine multiple result sets into single with or without duplicate. The union operation is different from a join, In Mathematical terms; a union is addition, whereas a join is multiplication. Instead of extending a row horizontally as a join would, the union combines multiple result sets into a single result set.

Let’s look at the example:

SELECT EmployeeID,Name,Salary,DOJ from Employee
UNION
SELECT EmployeeID,Name,Salary,DOJ from Employee_HIST

We are combining the results from Employee and Employee_HIST table. When you use UNION operator it will eliminate the duplicate records meaning that if the same record is in both the tables then it will pickup the record from only one table.

Let’s look at another example:

SELECT EmployeeID,Name,Salary,DOJ from Employee
UNION ALL
SELECT EmployeeID,Name,Salary,DOJ from Employee_HIST

Here also we are combining the results from Employee and Employee_HIST table. When you use UNION ALL operator it will not eliminate the duplicate records meaning if you have the same record in both tables then in the final output you will see both the records.

UNION is always creates the performance issue. So when ever you are using UNION use it very judiciously. If you are not sure of what kind of data you have then you can use UNION. If you know you don’t have any duplicate records for which you want to combine the results then use UNION ALL.

Find out SQL Server Version

There are several ways to find out the SQL Server Version, and this is one of the easiest way.

SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')

Cannot drop the table

The DROP TABLE command removes a table from the specified database. The specified table cannot be removed because it does not exist in the system catalog.

There could be several reasons,

Make sure the table name is correct.

Make sure you have sufficient access permission to drop the specified table.

If NOT then above ask your DBA to investigate the problem.

Wednesday, August 6, 2008

Primary key can't be created

The primary key is used to relate the table to foreign keys in other tables. All columns participating in a primary key must contain defined values other than NULL.

To create a primary key on the selected column, first clear the Nulls from that column.

Friday, August 1, 2008

My New Rank in C-Sharpcorner

In June, I spent most of the time in SQL Server Central community by posting answers because of that i was in TOP 5 in Montly TOP contributors. This was a great experience. Now In July, I spent most of the time in C-Sharpcorner, by posting answers to mainly C#, ASP.Net questions and other .Net Related questions.

As always Hard work pays, I am the MOST VALUABLE CONTRIBUTOR (MVC) in C# Corner. This is one more milestone in my Career.....


Sunday, July 27, 2008

CROSS JOIN in SQL Server

Let's look at the very rarely used join, which is CROSS join. The simplest ways of implementing the CROSS JOIN is remove the joining conditions on these tables.

So, for an ultra-quick example, let's take our first example from the CROSS JOIN section earlier in the chapter. The ANSI syntax looked like this:

SELECT * FROM CARMODELS CM CROSS JOIN COLORS C;

To convert it to the old syntax, we just strip out the CROSS JOIN keywords and add a comma:

SELECT * FROM CARMODELS CM, COLORS C;

OUTER JOIN in SQL Server

Let's look at the most widely used join, which is OUTER join. I will not focus on what are outer joins but will give how to us ANSI joins to write OUTER join queries.

There are two types of outer joins:
1) Left Outer Join or Left Join: *= symbol is used to implement this kind of join.
2) Right Outer Join or Right Join: =* symbol is used to implement this kind of join.

SELECT E.EMPID, M.EMPID AS ManagerID
FROM HRDETAILS.EMP E LEFT OUTER JOIN HRDETAILS.EMP M
ON E.MGRID = M.EMPID;

The above query is based on ANSI joins. Now let's rewrite this query using a WHERE clause–based join syntax.
It's very simple just replace "LEFT OUTER JOIN" with "," and then where ever you have ON condition replace that with either WHERE or AND condition depending on the conditions and joins in your query.

SELECT E.EMPID, M.EMPID AS ManagerID
FROM HRDETAILS.EMP E ,
HRDETAILS.EMP M
WHERE E.MGRID *= M.EMPID;

There will not be any difference in the out put.

INNER JOIN in SQL Sever

Let's look at the very basic join, which is INNER or EQUI JOIN

SELECT E.*
FROM HRDETAILS.EMP E
INNER JOIN HRDETAILS.EMP M
ON E.MGRID = M.EMPID;

The above query is based on ANSI joins. Now let's rewrite this query using a WHERE clause–based join syntax.

It's very simple just replace "INNER JOIN" with "," and then where ever you have ON condition replace that with either WHERE or AND condition depending on the conditions and joins in your query.

SELECT E.*
FROM HRDETAILS.EMP E ,
HRDETAILS.EMP M
WHERE E.MGRID = M.EMPID;

There will not be any difference in the out put.

Clustered index Criteria

Scenarios to have Clustered indexes:

1) If the query has a WHERE clause with operators like BETWEEN, >, >=, <, and <=.
2) If the query is returns large result sets.
3) If the query uses JOIN clauses.
4) The query accesses values in a column sequentially. For example, a query on EmployeeIDs between 10000 and 900000
5) If the query uses an ORDER BY clause or a GROUP BY clause. The index might remove the need to sort the data because the data is already ordered.

Criteria to create Clustered index:

1) Contains unique values or, failing that, contain mostly distinct values.
2) Are defined as IDENTITY. Each value in the column is known to be unique.
3) Are often used to sort data returned by a query. Having data in a clustered index that is already sorted in a desired order can save the cost of sorts during the query.

Criteria to not create Clustered index:

1) There is a wide key for each data row.
2) Values in the key columns undergo frequent changes. Because data in a clustered index is sorted on key column values, a change in those values means that data rows have to be moved into their correctly sorted positions after any changes.

Clustered index Vs Non-Clustered index

Primarily in SQL server there are two types of indexes, clustered index and Non-Clustered index. Let me give you very basic difference between these types of indexes. These two indexes are different in terms how the data is stored. In Clustered index the leaf-nodes contains the data where as in Non-clustered index leaf-nodes contains the bookmarks to the actual data. In other words data is sorted and stored based on the Clustered Index. So that’s the reason you can have only one Clustered index per table.

Friday, July 25, 2008

find a column in SQL Server

There are coupe of queries in my mail box about How to find out a particular Column and its details from all the columns in SQL Server.

This is one of finding the information.

select sysobjects.name as 'TableName', *
from syscolumns, sysobjects
where syscolumns.name='columnname'
and sysobjects.id = syscolumns.id
and (sysobjects.xtype='U' or sysobjects.xtype='S')

SQL Server Errors

Error:
'Problem in Connecting Database. error " SQL Server does not allow remote connections." '

Solution:
Incorrect Installation was the culprit.
Re-Install the same and everythign will workfine.

SQL Server Errors

Error:
Cannot drop database “DataBaseName” because it is currently in use.

Solution:
Close SQL Server Management Studio completely. Open it again and connect as normal. Now you will be able to drop the database with
USE master
GO
DROP DATABASE (databaseName)
GO

RoWNum in MS Access

There were couple of questions in my mail-box that is how to produce RowNum in MS Access queries??

After spending couple of hours finally this can be achieved with Sub-queries...is this great?

SELECT o1.EMPID, o1.ENAME,
(SELECT COUNT(*) FROM Emp AS o2
WHERE o2.Sal <= o1.Sal) AS RowNum
FROM Emp AS o1
ORDER BY o1.Sal

Happy Coding....

SHUTDOWN

SHUTDOWN command in SQL Server is used to stop SQL Server Services.


SHUTDOWN [ WITH NOWAIT ]

WITH NOWAIT clause is an Optional parameter. Shuts down SQL Server without performing checkpoints in every database. SQL Server exits after attempting to terminate all user processes. When the server restarts, a rollback operation occurs for uncompleted transactions.

If you dont use this clause then shutdown happens in the following fashion.

1. Disabling logins (except for members of the sysadmin and serveradmin fixed server roles).
2. Waiting for currently running Transact-SQL statements or stored procedures to finish.
3. Inserting a checkpoint in every database.

Thursday, July 10, 2008

GO in SQL Server

Today, I was looking at couple of forums and my mailbox and encountered the question "What is GO"? in SQL Server? is it a command?

I was able to reply to this question in all the forums but its really important for me to put this in blog so that my blog readers can get the information.

It is basicaclly signals the end of a batch of Transact-SQL statements. Its not a T-SQL statement and its a command recognized by the osql and isql utilities and SQL Query Analyzer. The current batch of statements is composed of all statements entered since the last GO, or since the start of the ad hoc session or script if this is the first GO.

USE pubs
GO
SELECT COUNT(*)
FROM authors
GO

This example creates two batches. The first batch contains only a USE pubs statement to set the database context and the next one is to retun the data.

My New Rank in SQL Sever Central

As you know i am one of the active member in Dotnetspider.com where i posted/answered 3200+ answers in last couple of years and wrote no.of articles and posted no.of code snippets. Now Its time to move on and set new goals to my self as a result started posting information on SQL Server Central, where it is mainly for SQL Server DB related questions.

As always hard-work always pays,

Friday, July 4, 2008

xp_cmdshell

Executes a given command string as an operating-system command shell and returns any output as rows of text. Grants nonadministrative users permissions to execute xp_cmdshell.

Executing this xp_cmdshell statement returns a directory listing of the current directory.


xp_cmdshell 'dir *.exe'

xp_cmdshell operates synchronously. Control is not returned until the command shell command completes.

When you grant execute permissions to users, the users can execute any operating-system command at the Microsoft Windows NT command shell that the account running Microsoft SQL Server™ has the needed privileges to execute.

By default, only members of the sysadmin fixed server role can execute this extended stored procedure. You may, however, grant other users permission to execute this stored procedure.

IIS 7.0

Windows Server 2008 featuring Internet Information Services 7.0 is a powerful Web application and services platform that delivers rich Web-based experiences. It offers improved administration and diagnostic tools to help achieve lower infrastructure costs on a variety of popular development platforms. With improved reliability and scalability, IT professionals and developers can manage the most demanding Web serving environments, from a single Web server to a large Web farm.

Download IIS @
http://www.microsoft.com/windowsserver2008/en/us/trial-software.aspx

special characters in SQL Server

There are several characters that have special meaning within a SQL query, for example the percent sign (%) in a LIKE query is a wildcard that essentially means "any number of characters can go here." Likewise, the underscore (_) is a wildcard that says "any single character can go here." So what if you are actually looking for a value that contains a literal percent sign? You will end up with bizarre results if you try the following:

SELECT columns FROM table WHERE
column LIKE '%%%'

Instead, you can try one of the following solutions:

SELECT columns FROM table WHERE
column LIKE '%[%]%'

-- or

SELECT columns FROM table WHERE
column LIKE '%\%%' ESCAPE '\'

The first query 'delimits' the special character with square brackets, telling the engine to treat it as a normal literal character instead of a character with special meaning. The second query uses a custom escape character -- you can use any character you like, just be careful that you aren't also expecting to use it as part of the literal string.

Method Overloading

In complex applications written in C#, we may need many methods which do essentially similar functions but are just different enough to be considered unique. For example, we may have to calculate a person's tax liability and would need to implement a method for doing this calculation in our application program. However, there are many different rules when it comes to tax calculations and they vary throughout the world. While there may be many rules, one basic equation stays the same: Your net income equals your gross income minus a computed tax amount. It is the method of computing your tax that varies.

We would probably have to implement different methods for each type of tax calculation. And, we could give each method a unique name such as TaxCalc1, TaxCalc2, TaxCalc3, etc. But wouldn't it be nice to just name the method TaxCalc and pass different arguments to it based on the computation desired?




For instance, let's say you live in a region within your country where you are taxed on your personal income, the value of your home, and any income you generate by doing business. On sales you generate through business activity, you must pay a gross receipts tax on all sales. If you own your home, you must pay a property tax on the imputed value of it. Then lastly, you must pay a tax on all income you generate through a job with another employer.

Check out the below link
http://www.codersource.net/csharp_method_overloading_ed.html

OOPS Concepts Part 1

To day i woule like to take a step back and give some information on OOPS concepts.

What Is an Object?
An object is a software bundle of related state and behavior. Software objects are often used to model the real-world objects that you find in everyday life. This lesson explains how state and behavior are represented within an object, introduces the concept of data encapsulation, and explains the benefits of designing your software in this manner.

What Is a Class?
A class is a blueprint or prototype from which objects are created. This section defines a class that models the state and behavior of a real-world object. It intentionally focuses on the basics, showing how even a simple class can cleanly model state and behavior.

What Is Inheritance?
Inheritance provides a powerful and natural mechanism for organizing and structuring your software. This section explains how classes inherit state and behavior from their superclasses, and explains how to derive one class from another using the simple syntax provided by the Java programming language.

What Is an Interface?
An interface is a contract between a class and the outside world. When a class implements an interface, it promises to provide the behavior published by that interface. This section defines a simple interface and explains the necessary changes for any class that implements it.

Keep watching.....