Saturday, September 13, 2008

Query to remove duplicate record from the table - Oracle

SELECT a.Employee_No,a.Employee_Name
FROM Employee_Contact a
where rowid >
(select min(rowid) from Employee_Contact b
where a.Employee_No = b.Employee_No
)

How to flush the word & excel file from the web site, using C#

System.IO.FileInfo file;

here sFile = your virtual file path (/myfiles/abc.xls)

file = new System.IO.FileInfo(sFile);
if (file.Exists)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;
filename=" + file.Name);

HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString());
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
HttpContext.Current.Response.WriteFile(file.FullName);
HttpContext.Current.Response.End();
System.GC.Collect();
}
else
{
HttpContext.Current.Response.Write("This file does not exist.");
}

How to kill/close the EXE's using C#

Below is the code to close word/excel exe uisng C#

Process[] eProcess;
eProcess = System.Diagnostics.Process.GetProcessesByName("EXCEL");
eProcess[0].Kill();


Process[] wProcess;
wProcess = System.Diagnostics.Process.GetProcessesByName("WINWORD");
wProcess[0].Kill();

Default redirect to https protocol -- for 403.4 Or 403- IIS setting

Please follow below steps for default redirection.

1) start > run -- type "inetmgr"
2) click ok
3) go to website > default websit
4) right click on default website
5) select properties
6) click on 'custom errors' tab
7) find 403.4 error code
8) give your redirection page path.
like 'c:/inetpub/wwwroot/redirect.htm"


Here is the code for "redirect.htm" page

Default rediret to https protocol -- for 403.4 Or 403

Please follow below steps for default redirection.

1) start > run -- type "inetmgr"
2) click ok
3) goto website > default websit
4) right click on default website
5) select properties
6) click on 'custom errors' tab
7) find 403.4 error code
8) give your redirection page path.
like 'c:/inetpub/wwwroot/redirect.htm"


Here is the code for "redirect.htm" page

How to pass the parameter using Ado.net to SQL & Oracle

1)
To pass parameter in SQL query OR stored procedure
use- NAME = @MYNAME
here- @MYNAME is parameter

2)
To pass parameter in Oracle query OR stored procedure
use: NAME = :MYNAME
here- :MYNAME is parameter