Friday, March 16, 2012

How to find the working days records in a month using SQL Server?

SELECT ActualTransactionDate FROM SubjectTransaction WHERE DATEPART(dw, ActualTransactionDate) IN (1, 7) and DATEPART (MONTH, ActualTransactionDate) IN (2)--Feb

Tuesday, February 21, 2012

How do I increase the connection limit for IIS 5.1 on Windows XP?

Make a command prompt window (start, run, cmd.exe) and issue these commands.

Step 1: cd \inetpub\adminscripts
Step 2: cscript adsutil.vbs set w3svc/MaxConnections 40
Step 3: iisreset

How to get the all time zone using C#.Net?

public static DataTable GetTimeZoneTable(bool caseSensitive)
{
var systemTimeZones = TimeZoneInfo.GetSystemTimeZones();
string displayName = string.Empty;
DataTable dt = new DataTable("timezones");
dt.Columns.Add("ID", typeof(string));
dt.Columns.Add("DisplayName", typeof(string));
dt.Columns.Add("BaseUtcOffsetMinutes", typeof(int));
dt.Columns.Add("SupportsDaylightSavingTime", typeof(bool));
dt.PrimaryKey = new DataColumn[] { dt.Columns["ID"] };

foreach (TimeZoneInfo timeZone in systemTimeZones)
{
displayName = timeZone.DisplayName;
if (!caseSensitive) { displayName = displayName.ToLower(); }
dt.Rows.Add(timeZone.Id, displayName, Convert.ToInt32(timeZone.BaseUtcOffset.TotalMinutes), timeZone.SupportsDaylightSavingTime);
}
dt.AcceptChanges();
return dt;
}

----------

DatatTabe dt = GetTimeZoneTable(true);

Monday, June 27, 2011

How to find the files from all the sub folders in C#.Net?

using System.IO;

string[] filePaths = Directory.GetFiles(@"C:\Kanna\", "*.jpg", SearchOption.AllDirectories);

How to round the decimal values in C#.Net?

string text = "19500.36";
decimal value;
if (decimal.TryParse(text, out value))
{
value = Math.Round(value);
text = value.ToString();
// Do something with the new text value
}
else
{
// Tell the user their input is invalid
}

Monday, February 28, 2011

How to find Gridview row?

protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
ImageButton btn = (ImageButton)sender;
GridViewRow row = (GridViewRow)btn.NamingContainer;

string value = GridView1.Rows[row.RowIndex].Cells[0].Text;
Session["value"] = value;
}

Wednesday, February 16, 2011

What is C# Guid.empty() equivalent in Sql Server?

C#
--
Guid.empty()

SQL
---
cast(cast(0 as binary) as uniqueidentifier)

Sunday, September 19, 2010

How to make CD Autorun?

For msi file. save as autorun.inf
=================================

[autorun]
ShellExecute=MyInstaller-1.0.0.msi
label=My CD Label
icon=MyIcon.ico

for exe file. save as autorun.inf
=================================

[autorun]
open=Test.exe
label=My CD Label
icon=MyIcon.ico

Often the program you want to run will not be located in the root directory of the CD. If that is the case you must include the path in autorun.inf:

[autorun]
open=folder1\folder1A\myfile.exe
icon=myicon.ico

Sometimes you may also need to pass an argument to the program to be auto played:

[autorun]
open=myprogram.exe /argument
icon=myicon.ico

To open the html file ‘index.htm’ would require:
===============================================

[autorun]
ShellExecute=index.htm
icon=index.htm

However, since some older versions of Windows do not support ‘ShellExecute’ a less elegant alternative would be:

[autorun]
open=command /c start index.htm
icon=index.htm

Thursday, September 16, 2010

What is difference between DELETE & TRUNCATE commands?

Delete command removes the rows from a table based on the condition that we provide with a WHERE clause. Truncate will actually remove all the rows from a table and there will be no data in the table after we run the truncate command.


TRUNCATE
TRUNCATE is faster and uses fewer system and transaction log resources than DELETE.
TRUNCATE removes the data by deallocating the data pages used to store the table’s data, and only the page deallocations are recorded in the transaction log.
TRUNCATE removes all rows from a table, but the table structure and its columns, constraints, indexes and so on remain. The counter used by an identity for new rows is reset to the seed for the column.
You cannot use TRUNCATE TABLE on a table referenced by a FOREIGN KEY constraint.
It cannot activate a trigger.
TRUNCATE can not be Rolled back using logs.
TRUNCATE is DDL Command.
TRUNCATE Resets identity of the table.
DELETE
DELETE removes rows one at a time and records an entry in the transaction log for each deleted row.If you want to retain the identity counter, use DELETE instead. If you want to remove table definition and its data, use the DROP TABLE statement.
DELETE Can be used with or without a WHERE clause
DELETE Activates Triggers.
DELETE Can be Rolled back using logs.
DELETE is DML Command.
DELETE does not reset identity of the table.

What is normalization and their different forms?

Database normalization is a data design and organization process applied to data structures based on rules that help build relational databases. In relational database design, the process of organizing data to minimize redundancy. Normalization usually involves dividing a database into two or more tables and defining relationships between the tables. The objective is to isolate data so that additions, deletions, and modifications of a field can be made in just one table and then propagated through the rest of the database via the defined relationships.


TypesDescription
1NFEliminate Repeating Groups Make a separate table for each set of related attributes, and give each table a primary key. Each field contains at most one value from its attribute domain.
2NFEliminate Redundant Data If an attribute depends on only part of a multi-valued key, remove it to a separate table.
3NFEliminate Columns Not Dependent On Key If attributes do not contribute to a description of the key, remove them to a separate table. All attributes must be directly dependent on the primary key
BCNFBoyce-Codd Normal Form If there are non-trivial dependencies between candidate key attributes, separate them out into distinct tables.
4NFIsolate Independent Multiple Relationships No table may contain two or more 1:n or n:m relationships that are not directly related.
5NFIsolate Semantically Related Multiple Relationships There may be practical constrains on information that justify separating logically related many-to-many relationships.
ONFOptimal Normal Form A model limited to only simple (elemental) facts, as expressed in Object Role Model notation.
DKNFDomain-Key Normal Form A model free from all modification anomalies.
Remember, these normalization guidelines are cumulative. For a database to be in 3NF, it must first fulfill all the criteria of a 2NF and 1NF database.
 
Feedback Form