Tuesday, April 28, 2009

Developers confused with microsoft products like .Net 3.5 ?

Hi,

Before some days I met my friends and asked microsoft has launched the Visual Studio 2010 with .Net Framework 4.0. I was really very happy to use it. But they (my friends) confused. They told me why microsoft launching new versions quickly. They told me that Microsoft has launched .Net 2.0 in 2005, .Net 3.5 in 2008 and now they have the version in .Net 4.0 2010. Just in distance of two years they have launched three different versions. Even developers have not used the 2.0 properly. May be microsoft has many intelligent software engineers who are developing new versions very quickly. Whatever we are not microsoft. :P

Some one also told me "Microsoft is not solving their problem in their existing product. But launches new version as earlier as others could not find the bugs in earlier version." So I like to ask you are you all now ready to use .net 4.0 2010. I know there are too many features in this version, but ask your self how much do you know about .net 2.0? You can write your comments here.....

Microsoft is very quickly launching new version. Is this good for you or not?

Regards,

Vijay Modi

Monday, April 20, 2009

Context Menu on Mouse Right Click for IE, FireFox Mozilla, Safari.

After long time, I like to write an article on JavaScript compatibility on different browsers. In this article I am creating a context menu on mouse right click. As we know we can easily create the context menu using javascript, but the main problem is the browser compatibility with this context menu. I am here giving some code to create a context menu. You can use this in any browser. I tested it in Internet Explorer 6.0, Firefox Mozilla 2.0 and Safari 3.0. It's working fine.

Copy and paste the following code in notepad and save it as TestContextMenu.html and test it.

=============================================================

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>¦¦-Browser Compatible Context Menu-¦¦</TITLE>
<META NAME='Generator' CONTENT='Javascript Context Menu'>
<META NAME='Author' CONTENT='Context Menu on Mouse Right Click'>
<META NAME='Keywords' CONTENT='Browser compatible context menu'>
<META NAME='Description' CONTENT='Internet Explorer IE, FireFox, Safari compatible context menu'>
<style>
<!–
.skin0
{
position:absolute;
width:165px;
border:2px solid black;
background-color:#eeddee;
font-family:Verdana;
line-height:20px;
cursor:default;
font-size:14px;
z-index:100;
visibility:hidden;
}
.menuitems
{
padding-left:10px;
padding-right:10px;
}
–>
</style>
<script language=javascript>
//Following function will fired when we click on the right click menu option.
function getSelText(obj)
{
menuobj.style.visibility='hidden'
alert(obj);
}
</script>
</HEAD>

<BODY><BR><BR><BR><BR><BR><BR><BR><BR><BR>
<CENTER>
<P><B>
<H2>Right Click on the document and select an option from the context menu. <BR>This example is tested in Internet Explorer 6.0, Mozila Firefox 2.0 and Safari 3.0. Its working fine in all these browser.<B> </H2><BR><H1>Hurrey…..</H1>
</P></CENTER>
<div id='ie5menu' class='skin0' onMouseover='highlightie5(event)' onMouseout='lowlightie5(event)' onClick='jumptoie5(event)' display:none>
<div class='menuitems' url='#' onmousedown=getSelText('Copy');>Copy</div>
<div class='menuitems' url='#' onmousedown=getSelText('Cut');>Cut</div>
<div class='menuitems' url='#' onmousedown=getSelText('Paste');>Paste</div>
<div class='menuitems' url='#' onmousedown=getSelText('New');>New</div>
<div class='menuitems' url='#' onmousedown=getSelText('Edit');>Edit</div>
<div class='menuitems' url='#' onmousedown=getSelText('Submit');>Submit</div>
</div>

<script language='JavaScript1.2'>
//set this variable to 1 if you wish the URLs of the highlighted menu to be displayed in the status bar
var display_url=0

var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all
if (ie5||ns6)
var menuobj=document.getElementById('ie5menu')

function showmenuie5(e)
{
//Find out how close the mouse is to the corner of the window
var rightedge=ie5? document.body.clientWidth-event.clientX : window.innerWidth-e.clientX
var bottomedge=ie5? document.body.clientHeight-event.clientY : window.innerHeight-e.clientY

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<menuobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
menuobj.style.left=ie5? document.body.scrollLeft+event.clientX-menuobj.offsetWidth : window.pageXOffset+e.clientX-menuobj.offsetWidth
else
//position the horizontal position of the menu where the mouse was clicked
menuobj.style.left=ie5? document.body.scrollLeft+event.clientX : window.pageXOffset+e.clientX

//same concept with the vertical position
if (bottomedge<menuobj.offsetHeight)
menuobj.style.top=ie5? document.body.scrollTop+event.clientY-menuobj.offsetHeight : window.pageYOffset+e.clientY-menuobj.offsetHeight
else
menuobj.style.top=ie5? document.body.scrollTop+event.clientY : window.pageYOffset+e.clientY

menuobj.style.visibility='visible'
return false
}

function hidemenuie5(e)
{
menuobj.style.visibility='hidden'
}

function highlightie5(e)
{
var firingobj=ie5? event.srcElement : e.target
if (firingobj.className=='menuitems'||ns6&&firingobj.parentNode.className=='menuitems')
{
if (ns6&&firingobj.parentNode.className=='menuitems') firingobj=firingobj.parentNode //up one node
firingobj.style.backgroundColor='#00AAff'
firingobj.style.color='white'
if (display_url==1)
window.status=event.srcElement.url
}
}

function lowlightie5(e)
{
var firingobj=ie5? event.srcElement : e.target
if (firingobj.className=='menuitems'||ns6&&firingobj.parentNode.className=='menuitems')
{
if (ns6&&firingobj.parentNode.className=='menuitems')
{
firingobj=firingobj.parentNode;
}
firingobj.style.backgroundColor='' ;
firingobj.style.color='black' ;
window.status='';
}
}

function jumptoie5(e)
{
var firingobj=ie5? event.srcElement : e.target;
if (firingobj.className=='menuitems'||ns6&&firingobj.parentNode.className=='menuitems')
{
if (ns6&&firingobj.parentNode.className=='menuitems') firingobj=firingobj.parentNode;
if (firingobj.getAttribute('target'))
window.open(firingobj.getAttribute('url'),firingobj.getAttribute('target'));
else
window.location=firingobj.getAttribute('url');
}
}

if (ie5||ns6)
{
menuobj.style.display='';
document.oncontextmenu=showmenuie5 ;
document.onclick=hidemenuie5;
}
</script>
</BODY>
</HTML>

==============================================================

Note: I came to know from some comments that the Code is not working. I here note that the code was not working due to the problem with " character. I don't know but it was encrypted. I retype the code here and think that it will work. Let me know if you found any problem. Thank you...
Enjoy this......

Reference: http://www.dynamicdrive.com

Wednesday, April 15, 2009

Syntax Difference between MS Sql and My Sql

I got some problem with the guys that they want to know the exact difference between the syntax of MS Sql and My Sql. So I like to write this article on this blog. As you see my articles, I have also write an article for the commercial difference between these two Databases. You can see this article on the following url:

http://vijaymodi.wordpress.com/2007/03/28/my-sql-vs-ms-sql/

Now I like to give the syntax difference between these two databases. Let me start it now...

> If you want to retrieve the first (Top) four rows from a table by using query you have to write TOP in MS Sql. While for the same purpose, you need to write LIMIT in mysql. The syntax are as follows:

MS SQL:
SELECT TOP(4) * FROM TableName ORDER BY FieldName

MY Sql:
SELECT * FROM TableName ORDER BY FieldName LIMIT 4

> My Sql can insert multiple rows at a time, while MS Sql cannot.

MS SQL:
INSERT INTO tablename VALUES (1,'AAA');
INSERT INTO tablename VALUES (2,'BBB');
INSERT INTO tablename VALUES (3,'CCC');

MY SQL:
INSERT INTO tablename
VALUES (1,'AAA') , (2,'BBB') , (3,'CCC');

> MSSQL doesn't have CHARACTER_LENGTH. Provides the LEN and DATALENGTH functions instead (the latter is especially valid for 'special' data types like the TEXT type).while MYSQL Provides CHARACTER_LENGTH.
Aliases: CHAR_LENGTH, LENGTH. Note that MySQL removes trailing (not leading) spaces from CHAR values before counting.

To See the other more important difference visit the following link:

http://troels.arvin.dk/db/rdbms/

Thursday, April 9, 2009

VS 2008 Beta 2 Silverlight Reference Problems

I have installed VS 2008 Beta 2, Silverlight Alpha Refresh and the Silverlight tools for VS.

Then I have created a SilverLightProject. But when I am going to build this project I am getting the following warnings:

The following reference not found:
'agclr'
'mscorlib'
'system'
'System.Core'
'system.Xml.core'
'system.silverlight'

I cannot understand why this problem is comming.

I tried on the net. But not getting any solution. Then I tyied the following and solve the problem.

First I Install the "Microsoft Silverlight Tools Alpha for Visual Studio 2008 Beta 2".

Then re open the Visual Studio SilveLightProject, which I was created before. Then tried to build it. Still facing the same problem.

Second I Install the "Microsoft Silverlight 1.1 Alpha".
Then re open the Visual Studio SilveLightProject, which I was created before. Then tried to build it. Its amazing....:) Its working fine now....

Its working now.

I found that before installaton of "Microsoft Silverlight 1.1 Alpha" that, there in "Program Files\Microsoft Silverlight" folder did not contan the above reference dll. So I was getting errors. But after complete this installation, I got these all dll's there and so my problem was solved.

So try like this. Enjoy the SilveLight.:)

Regards,
Vijay Modi

Thursday, April 2, 2009

Cannot insert explicit value for identity column in table 'tblTestTable' when IDENTITY_INSERT is set to OFF.

Suppose you have a table in MS Sql with two Columns.
CREATE TABLE [dbo].[tblTest](
[Test_Id] [int] IDENTITY(1,1) NOT NULL,
[Test_Name] [varchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
CONSTRAINT [PK_tblTest] PRIMARY KEY CLUSTERED
(
[Test_Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]

Now you are inserting the three values in this table:
Insert Into tblTest(Test_Name) values("Test1")
Insert Into tblTest(Test_Name) values("Test2")
Insert Into tblTest(Test_Name) values("Test3")

So your table will look like as follows:
1 Test1
2 Test2
3 Test3

Now you are deleting second row of the table using the following syntax:
DELETE From tblTest where Test_Id=2

Now you table will looks like the following:
1 Test1
3 Test3

Now you are going to insert a row with the following query:
Insert Into tblTest(Test_Id,Test_Name) values(2, "TestTemp2")

when you execute this query, you will face the following error:

This error is coming when we have a Identity Specification is 'Yes' and IsIdentity is also 'Yes', Identity Increament is set to(1/2/...).

So you are unable to insert this type of row, because sql know that the Test_Id is the Identity_Column and so you cannot insert the value which already inserted. So to resolve this error, you have to set the Column_Identity ON by using the following syntax.
SET IDENTITY_INSERT tblOrderItemStatus ON

Then try to insert the row using the above same query, which was as following:
Insert Into tblTest(Test_Id,Test_Name) values(2, "TestTemp2")

Now you need to reset the Column_Identity OFF. You can do it just by the following syntax:
SET IDENTITY_INSERT tblOrderItemStatus OFF

Is it resolve your problem. Howdy buddy?....