Showing posts with label Microsoft. Show all posts
Showing posts with label Microsoft. Show all posts

Sunday, November 22, 2009

Free Online Sessions

Lets finger crossed we have started Free Online Sessions

Session Details of 22nd November'2009


1. Declarative WebForms Routing by Chandrashekar Thota

2. Dynamic Metadata by Chandrashekar Thota

3. Silverlight Basics by Gaurav Arora

4. Microsoft Chart Control by Kiran Kumar Koyelada

Visit for more detail: http://hyderabadtechies.info/index.php/events

Thursday, May 21, 2009

Visual Studio 2010 Beta-I : Ready to work

Its a great day for all techie today.
Microsoft released its new Visual Studion version.

Finally, Visual Studio 2010 Beta-I is released and available to download.

Get the cheat Sheet at : http://blogs.msdn.com/danielfe/archive/2009/05/20/visual-studio-2010-beta-1-cheat-sheet.aspx

Sunday, May 3, 2009

Microsoft TechEd-2009

Lets cheers, its a good news for all Microsoft lovers.
Microsoft TechEd2009 will be conducting in Hyderabad from May13 to May15.

Main attention of the eve is Steven A. Ballmer,CEO Microsoft. This is the greatest and biggest eve in India and expecting to see a huge crowd from developer community.

To grab more details please visit : Microsoft TechEd2009.

Friday, April 17, 2009

Silverlight Games Site - Silverlight Club

Its a great day for me, on 01st April'2009 finally Silverlight Game Site launched.

The main motive of Silverlight Club is to promote Microsoft Silverlight . Tony John is the Founder and Admin of the Site. I am taking as a Webmaster of the site.

We are looking some good Silverlight Experts , also we are running a Contest on the Site for Silverlight Games.

Wednesday, March 25, 2009

MicroSoft Released - Silverlight 3- Beta

MicroSoft Released - Silverlight 3- Beta

MicroSoft Released its Silverlight3 beta in MIX [conference for designers and developers at Las Vegas].

Its available for download at:

1. MicroSOft Silverlight 3 SDK Beta 1
2. MicroSoft Silverlight 3 Tools Beta 1 for Visual Studio 2008 SP1
3. The MicroSoft 3 beta Runtime

Friday, January 23, 2009

Capturing CTRL+Keys using JavaScript

This is the practical scenario where sometime one wants to disallow Ctl+keys combinitions on web-pages.

Following Code-snippet tells the whole story:


<html>
<head>
<script language="JavaScript">
function testCtrlKeys(e)
{
//Create an array for all possible keys
var arrCtrlKeys = new Array('a', 'n', 'c', 'x', 'v', 'j');
var key;
var isCtrl;

if(window.event)
{
key = window.event.keyCode; //Valid only for Internet Explorer
if(window.event.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}

else
{
key = e.which; //this is other than IE
if(e.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}


//if ctrl is pressed check if other key is in forbidenKeys array
if(isCtrl)
{
for(i=0; i<arrCtrlKeys .length; i++)
{
//case-insensitive comparation
if(arrCtrlKeys[i].toLowerCase() == String.fromCharCode(key).toLowerCase())
{
alert('You have pressed CTRL + '
+String.fromCharCode(key)
+'.');

return false;
}
}
}
return true;
}
</script>

</head>
<body>
<form method="">
<div>
<h3>Test Key Combinition [Ctrl+A, Ctrl+N, Ctrl+C, Ctrl+X, Ctrl+V,Ctrl+J]</h3>
<input type="text" name="mytext"
onKeyPress="return testCtrlKeys(event);"
onKeyDown="return testCtrlKeys(event);" />
</div>
</body>
</html>


Note:
1. Copy/paste above code in text file and save it as "nameddoc.html" and run it into Explorer
2. Check the magic of capturing javascript keys.

Capturing MouseEvents Using JavaScript

Capturing Mouse Events Using JavaScript :


Sometime there is a need to disable MouseEvents for specific task(s) in Web-Pages.

The following code-snippet shows how to achieve the same :


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Capturing Mouse Events Using JavaScript</title>
</head>
<body>
<div>
<b> Testing with Link Button : </b>
<a href="javascript:void(null)"
onmousedown="return captureButton(event)" onmouseup="return preventOperation(event)"
onclick="return preventOperation(event)" ondblclick="return preventOperation(event)"
oncontextmenu="return preventOperation(event)"
>Click here with various mouse buttons to test</a>
</div>
<br/>
<div>
<b> Testing wuth Submit Button : </b>
<input name=btnG type=submit onmousedown="return captureButton(event)" onmouseup="return preventOperation(event)"
onclick="return preventOperation(event)" ondblclick="return preventOperation(event)"
oncontextmenu="return preventOperation(event)">
</div>
<br/>
<div>
<b> Testing with Input Text : </b>
<input name=btnG type=text onmousedown="return captureButton(event)" onmouseup="return preventOperation(event)"
onclick="return preventOperation(event)" ondblclick="return preventOperation(event)"
oncontextmenu="return preventOperation(event)">
</div>

<script language="Javascript">
function captureButton(event)
{
var button;
if (event.which == null)
button= (event.button < 2) ? "MOUSE BUTTON : LEFT" :
((event.button == 4) ? "MOUSE BUTTON : MIDDLE" : "MOUSE BUTTON : RIGHT");
else
button= (event.which < 2) ? "MOUSE BUTTON : LEFT" :
((event.which == 2) ? "MOUSE BUTTON : MIDDLE" : "MOUSE BUTTON : RIGHT");
alert(button);
preventOperation(event);
}
function preventOperation(event)
{
if (event.preventDefault)
event.preventDefault();
else
event.returnValue= false;
return false;
}
</script>

</body>
</html>



Copy paste above code in a text document and named it as MouseEvents.html
Now test the same.

Get MicroSoft SDK's under single roof

Now MicroSoft SDK's are available in a single page.

One can get download required SDK's from the page MicroSOft SDK's.

The are under heads :

1. Azure Services Platrform
2. Office
3. Windows Desktop
4. Devices
5. Games
6. Server Technologies
7. Others

If need any kind of assistant, please fell free to contact me.

Monday, October 13, 2008

Silverlight2.0 : releases on Monday

Get ready for Silverlight2.0 release on Monday

I got the news from one of my friend and want to share the same with you. MicroSoft decided to release Silverlight2.0 on Monday.

I have not more for its:
    1. Features
    2. Working
    3. New implementations
    4. Flexibility etc.

Only the idea is that its a great inventions in the new era.

For more information pelase visit : http://news.cnet.com/8301-13860_3-10063722-56.html

Sunday, August 10, 2008

MicroSoft's Greatest Release : SQL Server 2008

On Wednesday MicroSoft releases SQL Server 2008 .

This is the great invention to the older ones' like SQL Server 2000 and SQL Server 2005. But, all the work is not put ahead Microsoft on top in the Warehouse Market. There are still Oracle, IBM abd TeraData.

For viewers and MicroSoft Well-wishers [like me...] are very much happy to read this news.

Lets share the news and celebaret the among our world.

For more info visit :
http://www.informationweek.com/shared/printableArticle.jhtml?articleID=209903873

Moonlight : Handles Silverlight Application in Unix

As you knew that Mono project provides the platform to run .Net application on UNIX. Now, there is a new term Silverlight in the field of .Net so, what about the UNIX fellows.
Will they stand alone?
No, Mono has decided to plan Moonlight which runs on Unix for Silverlight.

To do the same:
-One need SDK
-Build Silverlight program

For more detail please visit: http://www.mono-project.com/Moonlight

Mono Project - CAS

I have very little idea about Mono Project, it is a Software platform which helps to develop cross-platform applications. This is a great one helps us to run .net on Unix.
It has C# Compiler http://www.mono-project.com/CSharp_Compiler, Mono Runtime http://www.mono-project.com/Mono:Runtime,
These all are as per ECMA http://www.mono-project.com/ECMA
In Version Mono 1.2 there is no security model like CAS – Code Access Security, but in future version Mono will be with CAS.

For more information please visit : http://www.mono-project.com/CAS

Thursday, May 29, 2008

How to retrieve column names using datareader? - Part II

<!--

* The code snippet tells how to retrieve fields

* using datareader for, this is a part of :

* Book: C#2005 Beginners: A Step Ahead

* Written by: Gaurav Arora [gaurav.aroraose@yahoo.co.in]

-->

<%@ Page Language="C#" %>

<%@ Import Namespace="System.Web" %>

<%@ Import Namespace="System.Data" %>

<%@ Import Namespace="System.Data.SqlClient" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<script runat="server">



SqlConnection myCon = new SqlConnection("Server=localhost;database=HRnPAYROLL;trusted_Connection=true");

SqlCommand myCmd = null;

SqlDataReader myDr = null;

SqlDataAdapter myDa = null;

DataSet myDs = null;

String strOutPut = string.Empty;

protected void Page_Load(object sender, EventArgs e)

{

Getfields_DataReader();

Getfields_DataReader_SchemaOnly();

Getfields_DataSet();

}

/// <summary>

/// Retrieves all filed/column names of DataReader using GetName method without SchemaOnly

/// </summary>

protected void Getfields_DataReader()

{

myCmd = new SqlCommand("Select * from Employees", myCon);

myCon.Open();

myDr = myCmd.ExecuteReader();

//Store total number of Columns

Int32 totCol = myDr.FieldCount; //Fiedl count returns the number of total columns

Response.Write("<div class=\"upperColumn\">");

Response.Write("<h1>Retrieves All Field Names from DataReader using GetName Without SchemaOnly</h1>");


strOutPut = "<table border=\"1\"><tr> <td>Column Name</td> <td>Data Type</td></tr>";


for (Int32 intCol = 0; intCol < totCol; intCol++)

{

strOutPut += "<tr><td>" + myDr.GetName(intCol) + "</td>";

strOutPut += "<td>" + myDr.GetFieldType(intCol) + "</td></tr>";


}

strOutPut += "</table>";

//Write the output

Response.Write("<br/>" + strOutPut + "</Div> <br class=\"clear\" />");

myCon.Close();


}

/// <summary>

/// Retrieves all filed/column names of DataReader using SchemaOnly

/// </summary>

protected void Getfields_DataReader_SchemaOnly()

{

myCmd = new SqlCommand("Select * from HR_MAST_DEPT", myCon);

myCon.Open();

myDr = myCmd.ExecuteReader(CommandBehavior.SchemaOnly);

//Store total number of Columns

Int32 totCol = myDr.FieldCount; //Fiedl count returns the number of total columns

Response.Write("<div class=\"content\"> <div class=\"bottomColumn\">");

Response.Write("<h1>Retrieves All Field Names from DataReader using SchemaOnly</h1>");


strOutPut = "<table border=\"1\"><tr> <td>Column Name</td> <td>Data Type</td></tr>";


for (Int32 intCol = 0; intCol < totCol; intCol++)

{

strOutPut += "<tr><td>" + myDr.GetName(intCol) + "</td>";

strOutPut += "<td>" + myDr.GetFieldType(intCol) + "</td></tr>";


}

strOutPut += "</table>";

//Write the output

Response.Write("<br/> " + strOutPut + "</Div> </Div><br class=\"clear\" />");

myCon.Close();


}


/// <summary>

/// Retrieves all filed/column names of DataSet using ColumnName

/// </summary>

protected void Getfields_DataSet()

{


myDa = new SqlDataAdapter("Select * from Employees", myCon);

myDs = new DataSet();

myDa.Fill(myDs);

Response.Write("<div class=\"content\"> <div class=\"rightColumn\">");

Response.Write("<h1>Retrieves All Field Names from DataSet ColumnName</h1>");


strOutPut = "<table border=\"1\"><tr> <td>Column Name</td> <td>Data Type</td></tr>";


for (Int32 intCol = 0; intCol < myDs.Tables[0].Columns.Count; intCol++)

{

strOutPut += "<tr><td>" + myDs.Tables[0].Columns[intCol].ColumnName + "</td>";

strOutPut += "<td>" + myDs.Tables[0].Columns[intCol].DataType + "</td></tr>";


}

strOutPut += "</table>";

//Write the output

Response.Write("<br/> " + strOutPut + "</Div> </Div>");

}


</script>


<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<style type="text/css">

.content

{

margin:auto;

width:600px;

background-color:white;

border:Solid 2px orange;

}


html

{

background-color:gray;

font:14px Georgia,Serif,Garamond;

}


h1

{

color:Green;

font-size:18px;

border-bottom:Solid 1px orange;

}

.lbl

{

color:green;

font-weight:bold;

}


.upperColumn

{



margin:auto;

width:500px;

border:Solid 2px orange;

background-color:white;

padding:10px;

}

.bottomColumn

{



margin:auto;

width:700px;

border:Solid 2px orange;

background-color:white;

padding:10px;

}

.leftColumn

{ float:left;

width:300px;

height:150px;

border-right:Solid 1px gray;

background-color:white;

padding:5px;

}

.rightColumn

{ float:left;

height:150px;

border-left:Solid 1px gray;

padding:5px;

}

.clear

{

clear:both;

}

</style>

<title>How to retrieve all field names of datareader</title>

</head>

<body>

<form id="form1" runat="server">

</form>

</body>

</html>

How to retrieve column names using datareader? - Part I

Sometimes, we people when doing a higher things had lost some basics from memories, the sam happened with me.

Yesterday [May 28, 2008] my supervisor asked me a bit question - "How to retrieve column names using datareader?" I was junked that time and noticed that I have lost something from my memories of basics.
Today, I have sit back with my PC and workout the problem and write following Code snippet for VS2005:

We need a table to attain the above task, following query will solve the problem:

/* This query is created a HRnPAYROLL DATABASE
* for use of different examples shown in
* Book: C#2005 Beginners: A Step Ahead
* Written by: Gaurav Arora */

--First Create HRnPAYROLL DATABASE
Create Database HRnPAYROLL
go

Use HRnPAYROLL

--Create Employees Table and fill data

Create Table Employees
(
ID Varchar(4) Primary Key,
FirstName Varchar(25) Default 'Gaurav',
LastName Varchar(25) Default 'Arora',
Age Varchar(4) Default '19'
)
go

--*****************************************************************************************************************
Insert Into Employees Values ('0001','Anil','Jain','37');
Insert Into Employees Values ('0002','Aman','Jain','35');
Insert Into Employees Values ('0003','Amanpreet','Singh','28');
Insert Into Employees Values ('0004','Anuradha','Bhatia','24');
Insert Into Employees Values ('0005','Archana','Garg','25');
Insert Into Employees Values ('0111','Babita','Gupta','33');
Insert Into Employees Values ('0112','Babban','Das','24');
Insert Into Employees Values ('0113','Babu','Ram','24');
Insert Into Employees Values ('0114','Babbu','Man','38');
Insert Into Employees Values ('0115','Balbir','Singh','24');
Insert Into Employees Values ('0201','Chaman','Lal','38');
Insert Into Employees Values ('0202','Charan','Das','37');
Insert Into Employees Values ('0203','Chander Bhan','Singh','49');
Insert Into Employees Values ('0204','Changej','Khan','24');
Insert Into Employees Values ('0205','Champak','Lal','18');
Insert Into Employees (ID,FirstName,Age) Values ( '0160',' AMIT KUMAR','21')
Insert Into Employees (ID,FirstName,Age) Values ( '0180',' ABHISHEK MISHRA','24')
Insert Into Employees (ID,FirstName,Age) Values ( '0181',' ARUN KUMAR','23')
Insert Into Employees (ID,FirstName,Age) Values ( '0184',' ASHUTOSH BAJPAYEE','21')
Insert Into Employees (ID,FirstName,Age) Values ( '0185',' ANIL KUMAR YADAV','21')
Insert Into Employees (ID,FirstName,Age) Values ( '0188',' ASHOK KUMAR PATHAK','25')
Insert Into Employees (ID,FirstName,Age) Values ( '0190',' ABHISHEK KUMAR SINGH','23')
Insert Into Employees (ID,FirstName,Age) Values ( '0194',' AMIT KUMAR THAKUR','22')
Insert Into Employees (ID,FirstName,Age) Values ( '0549',' BRIJESH CHANDRA','21')
Insert Into Employees (ID,FirstName,Age) Values ( '0558',' BRAJESH KUMAR','27')
Insert Into Employees (ID,FirstName,Age) Values ( '0560',' B.K. SINGH','31')
Insert Into Employees (ID,FirstName,Age) Values ( '0562',' BALBIR SINGH [MANGAT]','35')
Insert Into Employees (ID,FirstName,Age) Values ( '1244',' DHARMESH PANWAR','27')
Insert Into Employees (ID,FirstName,Age) Values ( '1296',' DEEPAK PRASAD','26')
Insert Into Employees (ID,FirstName,Age) Values ( '1320',' DEEPAK JAIN','30')
Insert Into Employees (ID,FirstName,Age) Values ( '2004',' FAKHRE MUBEEN','21')
Insert Into Employees (ID,FirstName,Age) Values ( '2466',' GAURAV ARORA','19')
Insert Into Employees (ID,FirstName,Age) Values ( '2480',' GURDEEP SINGH','34')
Insert Into Employees (ID,FirstName,Age) Values ( '2481',' GOPAL DATT SATI','27')
Insert Into Employees (ID,FirstName,Age) Values ( '3210',' KAHLON I.J. SINGH','26')
Insert Into Employees (ID,FirstName,Age) Values ( '3211',' INDRESH KUMAR PANDEY','35')
Insert Into Employees (ID,FirstName,Age) Values ( '3641',' JAI PRAKASH','27')
Insert Into Employees (ID,FirstName,Age) Values ( '3683',' JAYCHANDRA','27')
Insert Into Employees (ID,FirstName,Age) Values ( '3698',' J.K. SINGH','23')
Insert Into Employees (ID,FirstName,Age) Values ( '3700',' JEET NARAYAN SINGH','29')
Insert Into Employees (ID,FirstName,Age) Values ( '3701',' JIVENDRA KUMAR','29')
Insert Into Employees (ID,FirstName,Age) Values ( '4009',' KAPOOR SINGH','30')
Insert Into Employees (ID,FirstName,Age) Values ( '4057',' KISHAN LAMA','21')
Insert Into Employees (ID,FirstName,Age) Values ( '4110',' KRISHAN KUMAR MISHRA','33')
Insert Into Employees (ID,FirstName,Age) Values ( '4112',' K.B. CHOUBEY','33')
Insert Into Employees (ID,FirstName,Age) Values ( '4113',' KAISH UDDIN','35')
Insert Into Employees (ID,FirstName,Age) Values ( '4455',' LOKNATH BALBANTARAY','34')
Insert Into Employees (ID,FirstName,Age) Values ( '4801',' M.K. DEBROY','30')
Insert Into Employees (ID,FirstName,Age) Values ( '4884',' MADAN GIRI','21')
Insert Into Employees (ID,FirstName,Age) Values ( '4936',' MANJISH KUMAR','34')
Insert Into Employees (ID,FirstName,Age) Values ( '4946',' MADAN SINGH','24')
Insert Into Employees (ID,FirstName,Age) Values ( '4949',' MANOJ KUMAR TIWARI','21')
Insert Into Employees (ID,FirstName,Age) Values ( '4978',' MUKHTAR AHMED','18')
Insert Into Employees (ID,FirstName,Age) Values ( '4985',' MANOJ SAXENA','31')
Insert Into Employees (ID,FirstName,Age) Values ( '4987',' MANISH MISHRA','31')
Insert Into Employees (ID,FirstName,Age) Values ( '5263',' NEERAJ MAHAWAR','33')
Insert Into Employees (ID,FirstName,Age) Values ( '5271',' NIRAJ KUMAR SINHA','19')
Insert Into Employees (ID,FirstName,Age) Values ( '5272',' N.K. SINGH','21')
Insert Into Employees (ID,FirstName,Age) Values ( '5274',' NITIN GUPTA','32')
Insert Into Employees (ID,FirstName,Age) Values ( '5275',' NARESH KUMAR GUPTA','23')
Insert Into Employees (ID,FirstName,Age) Values ( '5612',' O.P. YADAV','32')
Insert Into Employees (ID,FirstName,Age) Values ( '6135',' PRAMOD SINGH RAWAT','30')
Insert Into Employees (ID,FirstName,Age) Values ( '6136',' PRAMOD KUMAR GAUTAM','22')
Insert Into Employees (ID,FirstName,Age) Values ( '6137',' PRAMOD KUMAR SINHA','31')
Insert Into Employees (ID,FirstName,Age) Values ( '6138',' PRASAD SASNUR','20')
Insert Into Employees (ID,FirstName,Age) Values ( '6700',' R. BHATTACHARJEE','21')
Insert Into Employees (ID,FirstName,Age) Values ( '6753',' RAMA SHANKAR','20')
Insert Into Employees (ID,FirstName,Age) Values ( '6765',' RAMESH CHANDRA','27')
Insert Into Employees (ID,FirstName,Age) Values ( '6776',' RAMU YADAV','20')
Insert Into Employees (ID,FirstName,Age) Values ( '6899',' RAVINDER LAMBA','29')
Insert Into Employees (ID,FirstName,Age) Values ( '6925',' RAVINDRA KUMAR RANA','24')
Insert Into Employees (ID,FirstName,Age) Values ( '6996',' R.P. YADAV','28')
Insert Into Employees (ID,FirstName,Age) Values ( '7010',' RAJESH PUNDIR','33')
Insert Into Employees (ID,FirstName,Age) Values ( '7011',' RAJIV CHAUDHARY','32')
Insert Into Employees (ID,FirstName,Age) Values ( '7012',' RAVINDRA YADAV','23')
Insert Into Employees (ID,FirstName,Age) Values ( '7013',' RAJESH SHARMA','32')
Insert Into Employees (ID,FirstName,Age) Values ( '7016',' RAVI SHANKAR','19')
Insert Into Employees (ID,FirstName,Age) Values ( '7017',' RAM BILAS CHOUDHARY','23')
Insert Into Employees (ID,FirstName,Age) Values ( '7022',' RAJ KISHORE RAI','24')
Insert Into Employees (ID,FirstName,Age) Values ( '7023',' R. RAMESH','35')
Insert Into Employees (ID,FirstName,Age) Values ( '7123',' SATISH KUMAR','32')
Insert Into Employees (ID,FirstName,Age) Values ( '7296',' SHANKAR LAL','29')
Insert Into Employees (ID,FirstName,Age) Values ( '7471',' SANJEEVAN M.K.','30')
Insert Into Employees (ID,FirstName,Age) Values ( '7480',' SANDEEP KR. SHRIVASTA','34')
Insert Into Employees (ID,FirstName,Age) Values ( '7484',' SUBHARAM BANERJEE','25')
Insert Into Employees (ID,FirstName,Age) Values ( '7490',' S.M. TRIPATHI','31')
Insert Into Employees (ID,FirstName,Age) Values ( '7501',' TEK BAHADUR CHATTRI','23')
Insert Into Employees (ID,FirstName,Age) Values ( '7513',' TULSI PRASAD','30')
Insert Into Employees (ID,FirstName,Age) Values ( '7919',' UMESH CHANDRA MISHRA','19')
Insert Into Employees (ID,FirstName,Age) Values ( '8480',' VIVEK TRIPATHI','31')
Insert Into Employees (ID,FirstName,Age) Values ( '8481',' VIJAY KUMAR','22')
Insert Into Employees (ID,FirstName,Age) Values ( '8485',' VIJAY KUMAR MISHRA','20')
Insert Into Employees (ID,FirstName,Age) Values ( '8486',' VINEET KUMAR SAXENA','35')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J001',' ANURAG', 'MISHRA','21')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J002',' ANURAG', ' DWIVEDI','24')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J006',' A.B.', ' KATIYAR','23')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J007',' AJAY', ' NAGAR','21')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J009',' AMIT KUMAR', ' SINGH','21')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J011',' AKHILESH KUMAR', ' VERMA','25')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J012',' ASHUTOSH', ' SRIVASTVA','23')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J013',' AKHILESH', ' BABU','22')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J018',' ASHOK KUMAR', ' PAL','21')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J019',' ANIL KUMAR', ' SINGH','27')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J023',' AMRISH', ' SHARMA','31')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J151',' CHANDRA PRATAP', ' SINGH','35')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J152',' C.P.', ' MISHRA','27')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J201',' DILIP', ' NAYAK','26')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J204',' DHEERAJ KUMAR', ' SACHAN','30')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J205',' DEVBRAT', ' SINGH','21')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J209',' DINESH', ' MISHRA','19')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J210',' DHARMENDRA KR.', ' PANDEY','34')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J316',' HEMANT', ' KUMAR','27')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J350',' JAGDISH', ' AWASTHI','26')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J366',' K.K.', ' KHULAR','35')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J371',' KAVIRAJ',' ','27')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J372',' KRISHNA KANT', ' SINGH','27')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J383',' LIBREN STENLY', ' LUGEN','23')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J384',' LING RAJ', ' SAHU','29')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J396',' MAHENDRA', ' PRAJAPATI','29')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J400',' MANJEET SINGH', ' REHSHI','30')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J403',' MAHENDRA', ' KHARAD','21')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J405',' MANPREET SINGH', ' JABBAL','33')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J411',' NEERAJ', ' TIWARI','33')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J416',' NARENDRA PRATAP', ' SINGH','35')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J417',' NARAYAN', ' SINGH','34')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J443',' PRAMOD KUMAR', ' SHARMA','30')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J444',' PRAFUL CHANDRA', ' RAI','21')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J445',' PRAKASH', ' SHARMA','34')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J447',' PRAVEEN KUMAR', ' DUBEY','24')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J448',' PRADEEP', ' KUMAR','21')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J450',' PRADEEP KR.', ' DWIVEDI','18')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J451',' PARTHA', ' CHOUDHARY','31')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J501',' RAM BABU', '','31')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J502',' RAJEEV', ' SHAHANI','33')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J508',' RAJEEV', ' LOCHAN','19')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J510',' RAJIV', ' KUMAR','21')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J551',' SANJAY', ' SINGH','32')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J554',' SUBODH', ' TIWARI','23')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J556',' SHIV SHANKAR', ' GOSWAMI','32')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J559',' SANJAY', ' TOMAR','30')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J562',' SURENDER', ' PAL SINGH','22')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J563',' SANDEEP', ' KUMAR','31')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J651',' T.', 'RAMESH','20')
Insert Into Employees (ID,FirstName,LastName,Age) Values ( 'J701',' UDAY RAJ', ' SINGH','20')

--*****************************************************************************************************************
-- Create HR_MAST_DEPT Table

CREATE TABLE HR_MAST_DEPT
(
[code] [char] (2) Primary Key ,
[Dpname] [varchar] (25) NOT NULL ,
[city] [varchar] (25),
[country] [varchar] (50),
[inhouse] [bit],

)
gO

-- Fill HR_MAST_DEPT Table

Insert Into HR_MAST_DEPT Values ( '10' , 'Information Technology' , 'Delhi' , 'India' , '1' )
Insert Into HR_MAST_DEPT Values ( '20' , 'Human Resources Dept' , 'Mohali' , 'India' , '1' )
Insert Into HR_MAST_DEPT Values ( '30' , 'Marketing' , 'Toronto' , 'Canada' , '0' )
Insert Into HR_MAST_DEPT Values ( '40' , 'Civil' , 'Calgiri' , 'Canada' , '0' )
Insert Into HR_MAST_DEPT Values ( '50' , 'Sales' , 'Gurgaon' , 'India' , '1' )
Insert Into HR_MAST_DEPT Values ( '60' , 'Commercial' , 'Delhi' , 'India' , '1' )
Insert Into HR_MAST_DEPT Values ( '70' , 'Admin' , 'Noida' , 'India' , '1' )
Insert Into HR_MAST_DEPT Values ( '80' , 'Testing' , 'Gurgaon' , 'India' , '1' )
Insert Into HR_MAST_DEPT Values ( '90' , 'Implementing' , 'Delhi' , 'India' , '1' )

--*****************************************************************************************************************

Saturday, May 10, 2008

Just-in-Time [JIT]

JIT compiler is a crucial component of the .NET framework. The JIT compiler converts IL to machine code, which is then executed. The JIT compiler does not compile the entire code at once because it could hamper the performance of the program. It compiles the code at runtime, at the time it is called. The code that is compiled gets stored until the execution comes to an end. This avoids recompilation of code.

Types of JIT
There following three types of JIT:
Pre-JIT
It compiles whole source code into native code in a single compilation cycle. This is done at the time of deployment of the application
Econo-JIT
It compiles only those methods that are called at runtime. However, these methods are removed when they are not required.
Normal-JIT
It also compiles only those methods which are called at runtime. These methods are compiled the first time they are called, and then they are stored in cache. When the same methods are called again, the compiled code from cache is used for execution

Common Language Runtime [CLR]

Let's rewind our mind to ancient era, when there is no existence of CLR concept, what happened when we invoke the language program or code. Basically, languages consist both compiler and runtime environment. Compiler converts or compiles code to executable files [known as PE (Portable file) files], which can be run by the users, in the other hand runtime environment provides O.S. [Operating System] services to executable code. Now at that time each language has its own runtime environment. Like Visual Basic contained MSVBVM60.DLL, Visual C++ contained MSVCRT40.DLL and for Java we need JRE [Java Runtime Environment] or JVM [Java Virtual machine].
But, with the invention of Common Language Runtime there is no need to gather individual runtime environment for individual languages, that's why .Net runtime is known as Common Language Runtime [CLR] Environment.

.NET framework

.NET framework is a Tool, which provides an environment for building, deploying and running web services and other application.

It also predicts from above figure that .NET framework [see fig11] consists of CLR and a single of unit of complete set of Class Libraries, provides the scarcity to develop Windows applications and Web Application with the help of .NET programming languages.

According to .NET documentation of Microsoft:
The .NET Framework is a new computing platform that simplifies application development in the highly distributed environment of the Internet. The .NET Framework is designed to fulfill the following objectives:

  1. To provide a consistent object-oriented programming environment whether object code is stored and executed locally, executed locally but Internet-distributed, or executed remotely.

  2. To provide a code-execution environment that minimizes software deployment and versioning conflicts.

  3. To provide a code-execution environment that guarantees safe execution of code, including code created by an unknown or semi-trusted third party.
    To provide a code-execution environment that eliminates the performance problems of scripted or interpreted environments.

  4. To make the developer experience consistent across widely varying types of applications, such as Windows-based applications and Web-based applications.

  5. To build all communication on industry standards to ensure that code based on the .NET Framework can integrate with any other code.

Stored procedure with a parameter and output parameter

The following example is for Microsoft SqlServer. One can try and run this is for learners.
Step-1 Create a Stored Procedure
CREATE PROCEDURE uspGetContact @LastName NVARCHAR(50), @ContactID INT output AS SELECT TOP 1 @ContactID = c.ContactID FROM HumanResources.Employee a INNER JOIN HumanResources.EmployeeAddress b ON a.EmployeeID = b.EmployeeID INNER JOIN Person.Contact c ON a.ContactID = c.ContactID INNER JOIN Person.Address d ON b.AddressID = d.AddressID WHERE c.LastName = @LastName

Step-2 After creating a stored procedure, run the below block of code. This will execute the above stored procedure and if the ContactID has a value it will also return the person and address info
DECLARE @ContactID INT SET @ContactID = 0 EXEC uspGetContact @LastName='Smith', @ContactID=@ContactID OUTPUT IF @ContactID <> 0 BEGIN SELECT ContactID, FirstName, LastName FROM Person.Contact WHERE ContactID = @ContactID SELECT d.AddressLine1, d.City, d.PostalCode FROM HumanResources.Employee a INNER JOIN HumanResources.EmployeeAddress b ON a.EmployeeID = b.EmployeeID INNER JOIN Person.Contact c ON a.ContactID = c.ContactID INNER JOIN Person.Address d ON b.AddressID = d.AddressID WHERE c.ContactID = @ContactID END

Tuesday, March 25, 2008

Working with Stored procedures

Stored procedure helps to make your work easy. With the help of these you just have to supply some parameters only.

The Code snippet using storedprocedures describes a way to use stored procedures.

Working with Transactions

Whenever you have to update more than one table or destinations then it must have to sure that the operation done successfully because some time it has been seen that one table updated but due to some error another(s) not. To overcome this problem you have Transactions.

In ADO.Net transactions are initiated by calling BeginTransaction() methods on the database connection object.

Transaction isolation levels


Isolation Level(s)

Description

ReadCommitted

Its default for SQL Server. It ensures that data written by one transaction will only be accessible in a second transaction after the first transaction commits.

ReadUnCommitted

It permits transaction to read data within the database, even data that have not yet been committed by another transaction.

RepeatableRead

It extends the ReadCommitted level, ensures that if the same statement issued within the transaction, regardless of other potential updates made to the database, the same data will always be returned.

Serializable

It is the most exclusive transaction level, which in effect serializes access to data within the database. With this level, phantom rows can never show up, so a SQ statement issued within a serializable transaction will always retrieve the same data.

Bellow is the code snippet to show transaction in action:

string myConStr = "server=(local); integrated security=SSPI;database=HRnPAYROLL";

using (SqlConnection myCon = new SqlConnection(myConStr))
{
//Open connection object
myCon.Open();
SqlTransaction nTran = myCon.BeginTransaction();
//some code for work
nTran.Commit();
}