Pages

Tuesday, April 2, 2013

How to find table names which have a specific column name in SQL Server?

In SQL Server Database, if you want to finds all the table names which have a specific column name field, you can use the JOIN query with "sys.tables" and "sys.columns" system tables. For example, if you want to find all the tables which have the column name "ITEM" use the following query,
SELECT t.name AS table_name,SCHEMA_NAME(schema_id) AS schema_name,c.name AS column_name 
FROM sys.tables AS t INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID WHERE c.name LIKE '%ITEM%' ORDER BY schema_name, table_name;


Thursday, March 28, 2013

How to put favicon (small image) in address bar of a web page?

First create a .ico image file. We could use the web site http://favicon.htmlkit.com/favicon to convert any picture to icon image. Now link that .ico image to your webpage using <link> tag in HTML <head> section. For example,
<link rel="shortcut icon" type="image/ico" href="~/Images/favicon.ico"/>

Tuesday, March 26, 2013

What is TCP Port?

Port is a 16-bit unique number that identifies  a specific software program on the server system. Ports are unique identifiers. For example, port 80 represents Web Server (HTTP) , port 21 represents FTP server and port 25 represents SMTP server. Without port numbers, the server system would have no way of knowing which application a client wanted to connect to. So, ports are just numbers that representing a server application. A server can have up to 65536 (0-65535) server application running. A TCP port numbers from 0 to 1023 are reserved for specific applications. Don't use these ports for your own custom server programs. 

How to pass parameter value for a subreport in Crystal Report

To set a parameter value for a parameter field in sub-report of a Crystal Report you may have to use the function

SetParameterValue(string parameterFieldName, object value, string subreport)
First create a ReportDocument object for main report and pass the parameter values to main report and subreports, for instance,
mainrpt = new ReportDocument();
ReportViewer.Enabled = true;
mainrpt.SetParameterValue("@ClmId", CLMID); // main report param
mainrpt.SetParameterValue("@Param1", ParamValue,"SubReport1.rpt"); //subreport param
mainrpt.SetParameterValue("@Param1", ParamValue,"SubReport2.rpt"); //subreport param
ReportViewer.ReportSource = mainrpt;
ReportViewer.Visible = true;

Wednesday, October 10, 2012

ASP.Net user authentication by using user name and password - Forms Authentication

What is Forms Authentication is ASP.Net?


If you needs to validate your own users authentication by providing user name and password, you have to establish a security settings on asp.net forms or each page request. To implement this mechanism ASP.Net provides an infrastructure is called  Forms authentication. The main advantage of Forms Authentication is, the basic user information, such as user name and password is stored in an encrypted authentication cookie (ticket). Forms Authentication is a token or ticket based system. When user log in, the basic user information should store on the token. So you can control the anonymous user access by implementing the token system.

How Forms Authentication works? 


When a user request an ASP.Net page, then ASP.Net run time verifies whether the forms authentication token is available, if not available, ASP.Net automatically redirect the user to a login page. If authentication token (cookie) is available, ASP.Net login page validate the user credentials and if the user successfully validate then redirect the user to the requested page.

Here you could find an example, how to implement a simple form based authentication.

How to exclude a page from Forms Authentication?


To exclude a page from forms authentication, you can use the <location> tag in web.config file. For example, (Please click on image to enlarge)


Here, registration.aspx page would be excluded from forms authentication. If you want to exclude a group of pages from forms authentication, you can add a folder name instead of a page name in the location path tag.