Sql Server Some Useful Query

This Query is Used to Create a new table from Existing Table
Select top 0 * into Demo from MaterialMaster

Sql Server Select Into Syntax
SELECT Id, Name INTO Employee_Temp FROM Employee WHERE Id > 1

Insert  Into Temporary Table
SELECT * INTO #MyContacts FROM Employee

How to Find Duplicate Records In Table

SELECT ColumnName,
COUNT(ColumnName) AS ColumnName
FROM tbl_Employee_M
GROUP BY ColumnName
HAVING ( COUNT(ColumnName) > 1 )

Asp.Net Enable Disable And Clear All Control

Asp.Net Enable – Disable Control

To Enable All Controls Which is in Panel Or any Other Form Comtrol Call this Function

DisableControls(this.PnlEdit);

private void DisableControls(Control parent)
{
foreach (Control _ChildControl in parent.Controls)
{
if ((_ChildControl.Controls.Count > 0))
{
DisableControls(_ChildControl);
}
else
{
if (_ChildControl is TextBox)
{
((TextBox)_ChildControl).Enabled = false;
}
else
if (_ChildControl is CheckBox)
{
((CheckBox)_ChildControl).Enabled = false;
}
if (_ChildControl is DropDownList)
{
((DropDownList)_ChildControl).Enabled = false;
}

}
}
}
private void EnableControls(Control parent)
{
foreach (Control _ChildControl in parent.Controls)
{
if ((_ChildControl.Controls.Count > 0))
{
EnableControls(_ChildControl);
}
else
{
if (_ChildControl is TextBox)
{
((TextBox)_ChildControl).Enabled = true ;
}
else
if (_ChildControl is CheckBox)
{
((CheckBox)_ChildControl).Enabled = true;
}
if (_ChildControl is DropDownList)
{
((DropDownList)_ChildControl).Enabled = true;
}

}
}
}

———————————————————————————————-

Same way to Clear all Control

private void ClearControls(Control parent)
{
foreach (Control _ChildControl in parent.Controls)
{
if ((_ChildControl.Controls.Count > 0))
{
ClearControls(_ChildControl);
}
else
{
if (_ChildControl is TextBox)
{
((TextBox)_ChildControl).Text = string.Empty;
}
else
if (_ChildControl is CheckBox)
{
((CheckBox)_ChildControl).Checked = false;
}

}
}
}

Asp.Net Crystal Report From XML File

Crystal Report From XML

To Generate Crystal Report From XML File in Asp.Net use followinf  code

Here Report.XML is an XML file in application

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;

public partial class _Default : System.Web.UI.Page
{
CrystalDecisions.Web.Report rpt = new CrystalDecisions.Web.Report();
CrystalDecisions.CrystalReports.Engine.ReportDocument rpt1;

protected void Page_Load(object sender, EventArgs e)
{
SqlConnection myConnection = new SqlConnection(“Data Source=SWAMI\\SQLEXPRESS;Initial Catalog=gifts;Integrated Security=True”);

string str = “select * from order_master where userid=’HetaDave'”;

SqlDataAdapter da = new SqlDataAdapter(str,myConnection );
DataSet ds = new DataSet();
da.Fill(ds);
ds.WriteXml(Server.MapPath(“Report.xml”));

rpt.FileName = Server.MapPath(“CrystalReport.rpt”);
crdata.Report = rpt;

rpt1 = crdata.ReportDocument;

crp.ReportSource = rpt1;
crp.DataBind();

}
}

Assembly In ASP Net

Assembly
We can say that assembly is a combination of single-file or multiple files in ASP NET.
The assembly which contains more then one file is dynamic link library (DLL) or we can also say it’s an EXE file.
In ASP.NET assembly contains metadata that is pronounced as assembly manifest.
This manifest of assembly contains data about the assembly versioning, AuthorName, Security,
Token Key etc that’s makes assembly popular and secure.

We can also say it’s a big advantage of assembly and another big advantage of using
ASP.NET Assemblies is that programmer need not to create applications without interfering with other
applications on the system its means assembly requirement in one application cannot harm another application
that using that assembly because assembly in one application is not applied to another application.

Differences Between Shared and Private Assemblies and how to use them.
Shared and Private Assembly: A private assembly is a assembly that is available to particular applications where they are kept. And cannot be references outside the scope of the folder where they are kept.
In contrast, Shared Assemblies are the assemblies that are accessible globally/shared across the machine to all the applications. For using the shared assemblies you need to register the assembly with a strong name in the global assembly cache(GAC) using gacutil.exe. GAC can be found on all the computers with .Net framework installed.

Asp.Net Javascript Numeric Validation For Textbox

<script language=”javascript” type=”text/javascript”>

function isNumeric(keyCode)
{
if(keyCode==16)
isShift = true;
return ((keyCode >= 48 && keyCode <= 57 || keyCode == 8 ||
(keyCode >= 96 && keyCode <= 105)) && isShift == false);
}

</script>

Call Javascript function on onkeydown Event Of Textbox

<asp:TextBox ID=”txtAppealNo” runat=”server” onkeydown = “return isNumeric(event.keyCode);”></asp:TextBox>

Sql Server Indexes

The concept behind indexes is to change the order of the data (clustered index)
or to add metadata (non-clustered index) for improving the performance of queries.

SQL Server use indexes to find data quickly when a query is processed.

Clustered indexes

Clustered indexes define the physical sorting of a database table’s rows in the storage media.
For this reason, each database table may have only one clustered index.
If a PRIMARY KEY constraint is created for a database table and no clustered index currently exists for that table,
SQL Server automatically creates a clustered index on the primary key.

* Physically stored in order (ascending or descending)
* Only one per table
* When a primary key is created a clustered index is automatically created as well.
* If the table is under heavy data modifications or the primary key is used for searches, a clustered index on the primary key is recommended.
* Columns with values that will not change at all or very seldom, are the best choices.

Non-clustered indexes

* Up to 249 nonclustered indexes are possible for each table or indexed view.
* The clustered index keys are used for searching therefore clustered index keys should be chosen with a minimal length.
* Covered queries (all the columns used for joining, sorting or filtering are indexed) should be non-clustered.
* Foreign keys should be non-clustered.
If the table is under heavy data retrieval from fields other than the primary key, one clustered index and/or one or more non-clustered indexes should be created for the column(s) used to retrieve the data.

Asp.Net GridView How to Check row in Gridview From Javascript

To check There Row in GridView From Javascript ]

Bind Grid View From dataSource and Take its rowcount in HiddenField

Take One HiddenField and Assign Gridview RowCount in That HiddenField

dgApprvOfficer.DataSource = dt;
dgApprvOfficer.DataBind();
HiddenField1.Value = dgApprvOfficer.Rows.Count.ToString();

function validate()
{

if (document.getElementById(“<%=HiddenField1.ClientID%>”).value == “” || document.getElementById(“<%=HiddenField1.ClientID%>”).value == “0”)
{
alert(“Please Enter Roe in Grid “);
return false;
}
}

Call Javascript Function From Code Behind

btnSave.Attributes.Add(“onclick”, “return validate()”);

How to Check Windows XP is 32 bit or 64 bit?

How to Check Windows XP is 32 bit or 64 bit?

Click Start,
Click Run,
Type winmsd.exe and then click OK.

It Will open System Information Window
In the details pane, locate Processor under Item. Note the value

If the value that corresponds to Processor starts with x86,
the computer is running a 32-bit version of the Windows operating system.

If the value that corresponds to Processor starts with EM64T or ia64,
the computer is running a 64-bit version of the Windows operating system.

Note: – Intel Itanium-based computers can only run 64-bit versions of Windows.
Intel Itanium-based computers cannot run a 32-bit Windows operating system.
Currently, 64-bit versions of Windows only run on Itanium-based computers and AMD64-based computer

Javascript Numeric Only TextBox Validation

function NumericOnly()
{
var key = window.event.keyCode;

if ( (key > 47 && key < 58) )
return;
else
// If it was not, then dispose the key and continue with entry
window.event.returnValue = null;
}

—————————————————————————-

Call This numeric Function On TextBox on KeyPress Event

OnKeyPress=”NumericOnly()”