Thursday, February 16, 2006

Oracle from unbreakable to unpatchable

Once upon a time Oracle was unbreakable but now it was broken several times and unable to plug the hole. Oracle PL/SQL Gateway, which allows a hacker to gain full administrative control of a back-end database from anywhere on the Internet. This is yet to get a patched and will be fixed in next quarter with fixes for 82 critical vulnerabilities all its products.
All because most people are not used to it does not mean you can claim it is unbreakable.


Courtesy: http://blogs.zdnet.com/Ou/?p=151&tag=nl.e622

Microsoft Office Live

Microsoft Live is now in Beta. In Beta everything is free. This includes own domain name, five email accounts 2 GB each, web traffic report, and website storage size of 30MB.

Dont wait click the following link http://officelive.microsoft.com/

Sunday, February 05, 2006

Aspnet_wp.exe could not be started

Last week I had a problem, When I moved to new machine. I was able install everything except ASP.NET, Then I checked the status of Aspnet_wp.exe, it was not running. I re-installed whole asp.net using aspnet_regiis.exe. I was bored and started searching. Then i found, it was due to security in related folders.


WORKAROUND
To work around this problem, verify that the ASPNET account has the correct user rights as follows:

• %windir%\Microsoft.NET\Framework\Version\Temporary ASP.NET Files: Full Control
• %windir%\Temp: Full Control
• Application folder: Read
• %installroot% hierarchy (for example, %windir%\Microsoft.Net\Framework\Version): Read
• %windir%\Assembly: Read

Note This is the global assembly cache. You cannot directly use Windows Explorer to edit ACLs for this folder. Instead, open a command window, and then run the following command:

cacls %windir%\assembly /e /t /p domain\useraccount:RAlternatively, before you use Windows Explorer, run the following command to unregister Shfusion.dll:
regsvr32–u shfusion.dll

After you set user rights in Windows Explorer, run the following command to re-register Shfusion.dll:
regsvr32 shfusion.dll

• Web site root (for example, %root%\Inetpub\Wwwroot) or the path that the default Web site points to: Read

• %windir%\System32: Read (Typically, the ASPNET account has already been granted user rights as a member of the Users group.)


Courtesy : http://support.microsoft.com/default.aspx?kbid=811320

How to remove duplicate rows from a table in SQL Server

How to remove duplicate rows from a table in SQL ServerWe sometime get into a situation, where we have to remove dulicate records from a given table. It is atedious process if we remove one by one. The following article will help you to remove duplicate records from a table

SUMMARY

Microsoft SQL Server tables should never contain duplicate rows, nor non-unique primary keys. For brevity, we will sometimes refer to primary keys as "key" or "PK" in this article, but this will always denote "primary key." Duplicate PKs are a violation of entity integrity, and should be disallowed in a relational system. SQL Server has various mechanisms for enforcing entity integrity, including indexes, UNIQUE constraints, PRIMARY KEY constraints, and triggers. Despite this, under unusual circumstances duplicate primary keys may occur, and if so they must be eliminated. One way they can occur is if duplicate PKs exist in non-relational data outside SQL Server, and the data is imported while PK uniqueness is not being enforced. Another way they can occur is through a database design error, such as not enforcing entity integrity on each table. Often duplicate PKs are noticed when you attempt to create a unique index, which will abort if duplicate keys are found.

This message is:
Msg 1505, Level 16, State 1 Create unique index aborted on duplicate key. If you are using SQL Server 2000 or SQL Server 2005, you may receive the following error message:

Msg 1505, Level 16, State 1 CREATE UNIQUE INDEX terminated because a duplicate key was found for object name '%.*ls' and index name '%.*ls'. The duplicate key value is %ls. This article discusses how to locate and remove duplicate primary keys from a table. However, you should closely examine the process which allowed the duplicates to happen in order to prevent a recurrence.

MORE INFORMATION
For this example, we will use the following table with duplicate PK values. In this table the primary key is the two columns (col1, col2). We cannot create a unique index or PRIMARY KEY constraint since two rows have duplicate PKs. This procedure illustrates how to identify and remove the duplicates.

create table t1(col1 int, col2 int, col3 char(50))insert into t1 values (1, 1, 'data value one')insert into t1 values (1, 1, 'data value one')insert into t1 values (1, 2, 'data value two')
The first step is to identify which rows have duplicate primary key values: SELECT col1, col2, count(*)FROM t1GROUP BY col1, col2HAVING count(*) < 1

This will return one row for each set of duplicate PK values in the table. The last column in this result is the number of duplicates for the particular PK value.
col1 col2
1 1 2
If there are only a few sets of duplicate PK values, the best procedure is to delete these manually on an individual basis. For example:

set rowcount 1delete from t1where col1=1 and col2=1
The rowcount value should be n-1 the number of duplicates for a given key value. In this example, there are 2 duplicates so rowcount is set to 1. The col1/col2 values are taken from the above GROUP BY query result. If the GROUP BY query returns multiple rows, the "set rowcount" query will have to be run once for each of these rows. Each time it is run, set rowcount to n-1 the number of duplicates of the particular PK value.

Before deleting the rows, you should verify that the entire row is duplicate. While unlikely, it is possible that the PK values are duplicate, yet the row as a whole is not. An example of this would be a table with Social Security Number as the primary key, and having two different people (or rows) with the same number, each having unique attributes. In such a case whatever malfunction caused the duplicate key may have also caused valid unique data to be placed in the row. This data should copied out and preserved for study and possible reconciliation prior to deleting the data.

If there are many distinct sets of duplicate PK values in the table, it may be too time-consuming to remove them individually. In this case the following procedure can be used:

1. First, run the above GROUP BY query to determine how many sets of duplicate PK values exist, and the count of duplicates for each set.

2. Select the duplicate key values into a holding table.
For example:SELECT col1, col2, col3=count(*)INTO holdkeyFROM t1GROUP BY col1, col2HAVING count(*) > 1

3. Select the duplicate rows into a holding table, eliminating duplicates in the process. For example:SELECT DISTINCT t1.*INTO holddupsFROM t1, holdkeyWHERE t1.col1 = holdkey.col1AND t1.col2 = holdkey.col2

4. At this point, the holddups table should have unique PKs, however, this will not be the case if t1 had duplicate PKs, yet unique rows (as in the SSN example above). Verify that each key in holddups is unique, and that you do not have duplicate keys, yet unique rows. If so, you must stop here and reconcile which of the rows you wish to keep for a given duplicate key value. For example, the query: S
ELECT col1, col2, count(*)FROM holddupsGROUP BY col1, col2

should return a count of 1 for each row. If yes, proceed to step 5 below. If no, you have duplicate keys, yet unique rows, and need to decide which rows to save. This will usually entail either discarding a row, or creating a new unique key value for this row. Take one of these two steps for each such duplicate PK in the holddups table.

5. Delete the duplicate rows from the original table.
For example:DELETE t1FROM t1, holdkeyWHERE t1.col1 = holdkey.col1AND t1.col2 = holdkey.col2 6. Put the unique rows back in the original table.
For example:INSERT t1 SELECT * FROM holddups

Courtesy::
http://support.microsoft.com/default.aspx?scid=kb;en-us;139444

Wednesday, February 01, 2006

Convert Julian Date to System.DateTime

Yesterday I had a requirement for converting Julian date to normal date and compare the date with a given date. I searched many times and I got Julian calendar and I didn't get any date conversion in .NET. But I got many examples in JavaScript how to convert Julian date to mm/dd/yyyy. I just converted JavaScript code to C#. Hope this helps to all you.


private DateTime ConvertJulianToDateTime(double julianDate)
{
DateTime date;
double dblA, dblB, dblC, dblD, dblE, dblF;
double dblZ, dblW, dblX;
int day, month, year;
try
{
dblZ = Math.Floor(julianDate + 0.5);
dblW = Math.Floor((dblZ - 1867216.25) / 36524.25);
dblX = Math.Floor(dblW / 4);
dblA = dblZ + 1 + dblW - dblX;
dblB = dblA + 1524;
dblC = Math.Floor((dblB - 122.1) / 365.25);
dblD = Math.Floor(365.25 * dblC);
dblE = Math.Floor((dblB - dblD) / 30.6001);
dblF = Math.Floor(30.6001 * dblE);
day = Convert.ToInt32(dblB - dblD - dblF);
if (dblE > 13)
{
month = Convert.ToInt32(dblE - 13);
}
else
{
month = Convert.ToInt32(dblE - 1);
}
if ((month == 1) (month == 2))
{
year = Convert.ToInt32(dblC - 4715);
}
else
{
year = Convert.ToInt32(dblC - 4716);
}
date = new DateTime(year, month, day);
return date;
}
catch (ArgumentOutOfRangeException ex)
{
MessageBox.Show("Julian date could not be converted:\n" + ex.Message, "Conversion Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
date = new DateTime(0);
}
catch (Exception ex)
{
MessageBox.Show("Error converting Julian date:\n" +
ex.Message, "Conversion Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
date = new DateTime(0);
}
return date;
}



To learn more about about Julian dates, visit http://quasar.as.utexas.edu/BillInfo/JulianDatesG.html