Friday, September 23, 2005
Cursor in SQL SERVER
DECLARE country CURSOR FOR SELECT PKID,CountryName FROM countryMaster
OPEN country
FETCH NEXT FROM country
WHILE @@FETCH_STATUS = 0
BEGIN
FETCH NEXT FROM country
END
CLOSE country
DEALLOCATE country
Thursday, September 15, 2005
HTC ( HTML Component )
If u wanna use the HTC,u have to give the style to corresponding controls.
Here I have attached the onblur to textbox.
This is ur HTML or ASPX Page
-----------------------------------
<INPUT TYPE="text" NAME="" style="behavior:url(sankar.htc)"/>
sankar.htc
-----------------------
<PUBLIC:ATTACH EVENT="onblur" ONEVENT="hi()">
<script language="javascript">
function hi()
{
alert(this.value);
}
</script>
Tuesday, July 05, 2005
Access the Page Values in C#
You can access the values of particular page done by this way.Context.Handler handles the page,So we can get the information from this handler
if(!IsPostBack)
{
if(Context.Handler.GetType().Name == "ListPJP_aspx" )
{
ListPJP ltp ;
ltp = (ListPJP)Context.Handler;
hideditid.Value = ltp.hidpkid.Value ;
string pagevalue =ltp.hidpageflag.Value;
}
}
Thursday, June 09, 2005
Interview
using System;
namespace temp
{
class test
{
void method (int a )
{
Console.WriteLine("first");
}
int method (int b )
{
Console.WriteLine("Second");
}
}
class Class1
{
[STAThread]
static void Main(string[] args)
{
test obj = new test();
obj.method(10);
}
}
}
Ans : It wil give the Compile time Error.Coz method overloading depends on the Same name with different Signatures not depends on the return type.Here return type may be different but signature is same.
----------------------------------------------------------
using System;
namespace temp
{
class Class1
{
static void Main(string[] args)
{
int i =20,k=0;
for (int j=1;j<i;j=1+4*(i/j))
{
k+=j<10?4:11;
}
Console.WriteLine(k);
Console.ReadLine();
}
}
}
What is output???
4
---------------------------------------------------------------
After which event,u cannot modify the ViewState???
If i am not maintain the viewstate what will i do???
What are all the CLR Components????
JIT
CLS
CTS
GC
Diff B/w Dataset and DataReader????
Diff b/w String and StringBuilder????
What are all diffrent ways creating Public assembly???
what is the diff between oninit and pageinit????
What will happen when you post the form???
Wednesday, June 01, 2005
Get the Number of weeks from particular Month
class MonthWeek
{
static void Main(string[] args)
{
DateTime dt = new DateTime(2005,2,1);
int days = DateTime.DaysInMonth(2005,2);
int week=0;
for(int i =1;i <= days ;i++)
{
if(dt.DayOfWeek.ToString()=="Sunday")
{
week += 1 ;
}
dt = dt.AddDays(1);
}
Console.WriteLine(week);
Console.ReadLine();
}
}
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)
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");
}
}
---------------------------------------------------
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
....
..
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
....
..
Tuesday, April 26, 2005
Find out all the IDENTITY Columns of all the Tables from the Database
Using COLUMNPROPERTY,OBJECTPROPERTY,you can get the primary key from INFORMATION_SCHEMA.COLUMNS table
COLUMNPROPERTY ( id , column , property )
Returns information about a column or procedure parameter.
OBJECTPROPERTY ( id , property )
Returns information about objects in the current database.
SELECT TABLE_NAME as TableName,
COLUMN_NAME as [Column],
DATA_TYPE as DataType
FROM INFORMATION_SCHEMA.COLUMNS
WHERE
COLUMNPROPERTY ( OBJECT_ID(TABLE_NAME), COLUMN_NAME, 'IsIdentity') = 1
AND OBJECTPROPERTY ( OBJECT_ID(TABLE_NAME), 'IsMSShipped') = 0
Monday, April 18, 2005
To Print A to Z Using SQL Query
This is Print A-Z
------------------------
DECLARE @LETTER CHAR(1),
@I INT
SET @I=65
WHILE(@I< = 90)
BEGIN
SET @LETTER = CHAR(@I)
SET @I=@I+1;
SELECT @LETTER
END
This is print a-z
---------------------------
DECLARE @LETTER CHAR(1),@I INT
SET @I=97
WHILE(@I< =122)
BEGIN
SET @LETTER = CHAR(@I)
SET @I=@I+1;
SELECT @LETTER
END
Sunday, April 17, 2005
Behind of JIT
The JIT compiler is responsible for performing a much more thorough verification process than the Class Loader perform.
The JIT verification process ensure s that only legal operations are performed against a cIass. It also ensures that the type being referenced is compatible with the type being accessed.
Security access permissions are also checked on various levels.
The JIT operates on the Concept that not all of an application's Code is always executed. Rather than waste CPU time and memory by converting an entire MSIL File to native code,the JITconverts only the code the application needs at any given time. This is one of the key strategies behind improving the performance and scalablity of applications written for the.NET Framework.
C# Method Call
using System;
namespace VirtualTest
{
public class a
{
public string a1()
{
return "base a1";
}
public string a2()
{
return "a2" ;
}
public string a3()
{
return "a3" ;
}
}
public class b : a
{
public string b1()
{
return "b1" ;
}
public string b2()
{
return "b2" ;
}
public string b3()
{
return "b3" ;
}
}
public class main
{
public static void Main()
{
a obja = new b();
string hi = obja.??????;
}
}
}
What are all the methods you can call for obja.
Ans : Base class method a1,a2,a3
Saturday, April 16, 2005
String Reverse without using reverse key word in C#
using System;
public class Entrance
{
public static void Main()
{
string str = "sankar";
Console.WriteLine(str.Length);
for(int i=str.Length-1;i>=0;i--)
{
Console.Write(str.Substring(i,1));
}
Console.ReadLine();
}
}
public class Entrance
{
public static void Main()
{
string str = "sankar";
Console.WriteLine(str.Length);
for(int i=str.Length-1;i>=0;i--)
{
Console.Write(str.Substring(i,1));
}
Console.ReadLine();
}
}
Comparison Datagrid,Datalist& Repeater
Both the DataGrid and DataList controls are derived from the WebControl class,
while the Repeater control is derived from the Control class.
The WebControl class contains a number of aesthetic properties, such as BackColor, ForeColor, CssClass, BorderStyle and so on. This means that with the DataGrid and DataList you can specify stylistic settings through the properties it inherits from the WebControl class. The Repeater, however, does not have any such stylistic properties. As we'll discuss in the "Digging Into the Repeater" section, any visual settings to the Repeater's output must be specified in the Repeater's templates.
There are five built-in DataGrid column types:
-------------------------------------------------
Bound Column
Button Column
Edit Column
HyperLink Column
Template Column
Template Supported By DataGrid
-----------------------------------
Item Template,
Header Template,
Footer Template
EditItem Template.
Template Supported By DataList
-----------------------------------
Item Template,
Header Template,
Footer Template
EditItem Template.
selectItem Template
separator Template
Tuesday, April 12, 2005
Shrink Database (MSSQL SERVER 2000)
You are maintaing the various Database in ur system while the space is also in ur consideration.If u wanna reduce the large space without deleting database, Run the query in ur SQL Query Analyzer
sp_helpdb 'databasename'
backup log DataBaseName with truncate_only
dbcc shrinkfile(databasename_log,10)
Now Check your Harddisk's Space,Really its reduce the space because of Shrinking operation.
sp_helpdb 'databasename'
backup log DataBaseName with truncate_only
dbcc shrinkfile(databasename_log,10)
Now Check your Harddisk's Space,Really its reduce the space because of Shrinking operation.
Case Sensitive Search in MSSQL
If you wanna get the Column Value from the Table With CaseSensitive
--------------------------------------------------------------------
SELECT * FROM TABLENAME
WHERE CONVERT(VARBINARY(50),COLUMNNAME) = CONVERT(VARBINARY,'COLUMNVALUE')
SELECT * FROM Employee
WHERE CONVERT(VARBINARY(50),EmpName) = CONVERT(VARBINARY,'SaNkar')
This query will return exact match of SaNkar.
--------------------------------------------------------------------
SELECT * FROM TABLENAME
WHERE CONVERT(VARBINARY(50),COLUMNNAME) = CONVERT(VARBINARY,'COLUMNVALUE')
SELECT * FROM Employee
WHERE CONVERT(VARBINARY(50),EmpName) = CONVERT(VARBINARY,'SaNkar')
This query will return exact match of SaNkar.
Thursday, April 07, 2005
Tuesday, April 05, 2005
Q & A
What is the Diff b/w Un-Safe Code and Un-managed Code ??
By un-safe code, it means that the managed program can access the memory address using pointers.
There are two points to remember here;
* Un-safe code is different from un-managed as it is still managed by the CLR
* You still can not perform pointer arithmetic in un-safe code.
Un-managed code runs outside the Common Language Runtime (CLR) control while the unsafe code runs inside the CLR’s control.
autoevent wireup attribute of page in asp.net??
If the value of the AutoEventWireup attribute is set
to false, you must override the OnInit function, and
then you must add a new delegate for the Page_Load
event handler
session concept.
Session is used to keep track of the particular user.
what is the defference between Response.Redirect and
Server.Transfer ??
Server.Transfer is used to post a form to another
page. Response.Redirect is used to redirect the user
to another page or site.
By un-safe code, it means that the managed program can access the memory address using pointers.
There are two points to remember here;
* Un-safe code is different from un-managed as it is still managed by the CLR
* You still can not perform pointer arithmetic in un-safe code.
Un-managed code runs outside the Common Language Runtime (CLR) control while the unsafe code runs inside the CLR’s control.
autoevent wireup attribute of page in asp.net??
If the value of the AutoEventWireup attribute is set
to false, you must override the OnInit function, and
then you must add a new delegate for the Page_Load
event handler
session concept.
Session is used to keep track of the particular user.
what is the defference between Response.Redirect and
Server.Transfer ??
Server.Transfer is used to post a form to another
page. Response.Redirect is used to redirect the user
to another page or site.
Monday, April 04, 2005
Interview 1
how authentication is done by sqlserver
If user entered in ur webapplication,At very first time of login only he can access a one value of ur application (first time only that value is accessible).....
Ans : Application_onStart
You cannot use the virtual modifier with the following modifiers:
static,abstract,override
You are creating the 3 windows service 1,2,3 on one system.when you install using instalutil.exe on cmd mode,while 2 services installed successfully but 3 rd service throw the error exception,In this situation how many windows services installed on that system.....
None
1
2
3
Ans : Idk very sure.None is my answer coz if any exception occur in cmd mode while we installing windows service, Transaction Rolled back error msg wil be displayed.
How to debug the Windows Service????
In Web.config,which part u customized ur application error?????
How to Filter the rows in dataview???
DataView dataViewForRegion =dsReport.Tables[0].DefaultView;
dataViewForRegion.RowFilter = "RegionID='Chennai'";
another one
if Chennai is variable
dataViewForRegion.RowFilter = "RegionID='"+Chennai+"'";
If u are not using Codebdhind Technique in ur code,At that time wat r all the code shoul be there ???
Ans: Page_Load (Sender obj,EventArgs e)
what about DataSet1.Merge(DataSet2)
If exception occured in ur webservice's webmethod,What exception it wil throw???
Ans : System.Web.Services.protocol.SoapException
If u want to improve the efficiency of ur webapplication,What are all the Steps u have to take????
eg >>> set Autoeventwireup = false
set EnableSessionstate = false
set SmartNavigation = false
I give the connection Pooling size is 50.If 51 th request wil come what will happen???
Ans : throws the Exception (server application is unavailable)
If user entered in ur webapplication,At very first time of login only he can access a one value of ur application (first time only that value is accessible).....
Ans : Application_onStart
You cannot use the virtual modifier with the following modifiers:
static,abstract,override
You are creating the 3 windows service 1,2,3 on one system.when you install using instalutil.exe on cmd mode,while 2 services installed successfully but 3 rd service throw the error exception,In this situation how many windows services installed on that system.....
None
1
2
3
Ans : Idk very sure.None is my answer coz if any exception occur in cmd mode while we installing windows service, Transaction Rolled back error msg wil be displayed.
How to debug the Windows Service????
In Web.config,which part u customized ur application error?????
How to Filter the rows in dataview???
DataView dataViewForRegion =dsReport.Tables[0].DefaultView;
dataViewForRegion.RowFilter = "RegionID='Chennai'";
another one
if Chennai is variable
dataViewForRegion.RowFilter = "RegionID='"+Chennai+"'";
If u are not using Codebdhind Technique in ur code,At that time wat r all the code shoul be there ???
Ans: Page_Load (Sender obj,EventArgs e)
what about DataSet1.Merge(DataSet2)
If exception occured in ur webservice's webmethod,What exception it wil throw???
Ans : System.Web.Services.protocol.SoapException
If u want to improve the efficiency of ur webapplication,What are all the Steps u have to take????
eg >>> set Autoeventwireup = false
set EnableSessionstate = false
set SmartNavigation = false
I give the connection Pooling size is 50.If 51 th request wil come what will happen???
Ans : throws the Exception (server application is unavailable)
Subscribe to:
Posts (Atom)