Wednesday, May 25, 2005

Get all Columns from the Table



create proc GetColumns
@TableName varchar(50)
as
BEGIN
DECLARE @str VARCHAR(8000)
SELECT @str = COALESCE(@str+',','')+
( SELECT COLUMN_NAME as [Column]
FROM INFORMATION_SCHEMA.COLUMNS UM1
WHERE UM1.COLUMN_NAME = UM2.COLUMN_NAME and
UM1.table_name=UM2.table_name
)
FROM INFORMATION_SCHEMA.COLUMNS UM2
where UM2.TABLE_NAME like @TableName

SELECT @str
END

Reset the Primary Column

If u are run this command,table primary column value reset to zero
DBCC CHECKIDENT (TableName, RESEED, 0)

Thursday, May 19, 2005

DOM

To View the DOM
---------------------------------------------------

var node = xmlDom.selectSingleNode("//HeaderTable");
for(var i=0; i < node.length ;i++ )
{
alert(node[m].xml);
alert(node[m].getAttribute("UserName"));
}


Dynamically Add the Row in the Tabel using DHTML
---------------------------------------------------
function addnew(tablename)
{
var table = get(tablename);
var objrow = table.insertRow(table.rows.length);
for(var i = 0; i < table.rows[0].cells.length; i++)
{

var cell = objrow.insertCell(i);
cell.className = table.rows[1].className;
cell.innerHTML = table.rows[1].cells[i].innerHTML;
cell.value="";


if(cell.parentNode.rowIndex!=1)
{
table.rows[cell.parentNode.rowIndex].cells[0].innerHTML=cell.parentNode.rowIndex;
}
}
}

Dynamically Delete the Row in the Tabel using DHTML
---------------------------------------------------



function deleterow(obj,tablename)
{

var table = get(tablename);
if(obj.parentElement.parentElement.rowIndex > 1 )
{
table.deleteRow(obj.parentElement.parentElement.rowIndex);

for(var i = 0; i < table.rows.length; i++) //Reshuffle the Serial Number
{
if(i!=0)
{
table.rows[i].cells[0].innerHTML = i;
}
}
}
else
{
alert("This row Cannot be deleted");
}

}

Monday, May 02, 2005

Print the number

using System;

namespace Printapplication
{
class Class1
{

static void Main(string[] args)
{
int n = Convert.ToInt32(Console.ReadLine());
for(int i=1;i<=n;i++) { for(int k=10-i;k>=1;k--)
{
Console.Write(" ");
}
for(int j=i;j>=1;j--)
{
Console.Write(j+" ");
}
Console.WriteLine(" ");
}

for(int s=n-1;s>=1;s--)
{
for(int t=10-s;t>=1;t--)
{
Console.Write(" ");
}
for(int u=s;u>=1;u--)
{
Console.Write(u+" ");
}
Console.WriteLine(" ");
}


Console.ReadLine();
}
}
}


output

5

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4
....
..