simple Java switch case

a simple problem that I encountered in Yahoo! Answers:

I want to go through the colors in my given Color [] colors; then once it goes through all 5 colors in the array, to start all over

Best solution I can think of is using a switch case:


//define Color[] colors = {color1, color2, color3, color4, color5};
int i=0;
while(true)
{
switch (i)
{
case 1: object.setColor(color1);
break;
case 2: object.setColor(color2);
break;
case 3: object.setColor(color3);
break;
case 4: object.setColor(color4);
break;
case 5: object.setColor(color5);
break;
default: object.setColor(color1); //when all else goes wrong
break;
}

if( i == 5 )
i = 1;
else
i++;
}

where is aspnet_regsql.exe located?

aspnet_regsql.exe takes care of creating/recreating the database tables, stored procedures, schema, and whatever else database objects needed for the ASP.Net Membership.

It is normally located in:

C:\WINDOWS\Microsoft.NET\Framework\(version number)\aspnet_regsql.exe

Remove Identity Constraint from Column (TSQL)

There's no way to remove an Identity Constraint from a column in a table, except through adding a new column, reassigning the Identity Column data to that new column then recreating the Identity Column (by drop and add) then reassigning back the data to it.

In the following code, I have a PrimaryKey ID that is also set as an Identity Column. What I want to do is to remove the Identity property by creating a new column name 'tempID' then temporarily storing the ID data into it while I recreate ID column so as to remove the Identity property.


ALTER TABLE [TableName]
ADD tempID int NULL
GO
UPDATE [TableName]
SET tempID=[IdentityColumnName]
GO


-- drop all foreign key constraints related to a table
-- see TSQL Script to drop all constraints

GO
ALTER TABLE [TableName]
DROP CONSTRAINT PK_[TableName]
GO
ALTER TABLE [TableName]
DROP COLUMN [IdentityColumnName]
GO
ALTER TABLE [TableName]
ADD [IdentityColumnName] int NULL

GO
UPDATE [TableName]
SET [IdentityColumnName]=tempID

GO
ALTER TABLE [TableName]
ALTER COLUMN [IdentityColumnName] int NOT NULL

GO
ALTER TABLE [TableName]
ADD CONSTRAINT PK_[TableName] PRIMARY KEY CLUSTERED ([IdentityColumnName]) ON [PRIMARY]
--or ADD CONSTRAINT [PrimaryKeyConstraintName]

GO


-- drop all foreign key constraints related to a table
-- see TSQL Script to drop all constraints

GO
ALTER TABLE [TableName]
DROP COLUMN tempID
GO

How to drop all Database connections (TSQL)

USE master
GO

ALTER DATABASE @dbName
SET OFFLINE WITH ROLLBACK IMMEDIATE
ALTER DATABASE @dbName
SET ONLINE

OR simply
Right Click database -> Tasks -> Take database offline

How to check/count Back Links

I wrote about How to Create Back Links previously.

Now let's see how to check for back links. This is useful for blogs, websites, etc.

On the Google search bar simply type
link:

For example
link:thingswelovetohate.blogspot.com
or
link:http://thingswelovetohate.blogspot.com

would result to the same number of back links.

You can determine how many back links a website has on the same window. Right above the search results, and right below the Search text box is a blue (in classic mode) highlighted line that shows how many results were found.

For example
link:www.mylot.com

back link backlink blogger site

You will see that it had a total of 142 back links at the time of the search.