Skip to main content

Posts

Showing posts from 2010

Error: "System.Web.HttpException: Maximum request length exceeded"

Problem When uploading large files in .NET, the following error may be received: System.Web.HttpException: Maximum request length exceeded...     This error relates to ASP.NET's maxRequestLength setting. By default,ASP.NET limits requests to 4096 kilobytes (or 4 MB), as explained inthis Microsoft KB article: http://support.microsoft.com/default.aspx?scid=kb;EN-US;295626 .  This error will occur if an upload is larger than 4 MB and you have notadjusted the maxRequestLength setting for your application inweb.config or machine.config.  To resolve this problem, use one of the following methods: In the Machine.config file, change the maxRequestLength attribute of the <httpRuntime> configuration section to a larger value. This change affects the whole computer. In the Web.config file, override the value of maxRequestLength for the application. For example, the following entry in Web.configallows files that are less than or equal to 8 megabytes (MB) to beuploaded...

How to create Web Setup Project in Visual studio 2005/2008

Steps: 1.       Create new ASP.NET Web Site a.       File->Add New Web Site->, Select ASP.net Web Site from template  and choose location file type or http   2.       Right click on website and then add Web Deployment project (WebSite1_deploy”) If Web Deployment project is not display in IDE then download from http://msdn.microsoft.com/en-us/asp.net/aa336619.aspx   for visual studio 2005 and  http://www.microsoft.com/DOWNLOADS/details.aspx?FamilyID=0aa30ae8-c73b-4bdd-bb1b-fe697256c459&displaylang=en for visual studio 2008 . Install Web Deployment project and then restart your visual studio IDE. Then you can see Web Deployment project  in Build menu “Add Web Deployment Project”.   3.       Right click on WebSite1_deploy then click on Build After successful build             ...

MAX Function : SQL SERVER

The MAX function returns the maximum value of an expression. The syntax for the MAX function is: SELECT MAX(expression ) FROM tables WHERE predicates; Simple Example For example, you might wish to know the maximum salary of all employees. SELECT MAX(salary) as "Highest salary" FROM employees; In this example, we've aliased the max(salary) field as "Highest salary". As a result, "Highest salary" will display as the field name when the result set is returned. Example using GROUP BY In some cases, you will be required to use a GROUP BY clause with the MAX function. For example, you could also use the MAX function to return the name of each department and the maximum salary in the department. SELECT department, MAX(salary) as "Highest salary" FROM employees GROUP BY department; Because you have listed one column in your SELECT statement that is not encapsulated in the MAX function, you must use a GROUP BY clause. The depar...

Joins Operator: SQL SERVER

A join is used to combine rows from multiple tables. A join is performed whenever two or more tables is listed in the FROM clause of an SQL statement. There are different kinds of joins. Let's take a look at a few examples. Inner Join (simple join) Chances are, you've already written an SQL statement that uses an inner join. It is the most common type of join. Inner joins return all rows from multiple tables where the join condition is met. For example, SELECT suppliers.supplier_id, suppliers.supplier_name, orders.order_date FROM suppliers, orders WHERE suppliers.supplier_id = orders.supplier_id; This SQL statement would return all rows from the suppliers and orders tables where there is a matching supplier_id value in both the suppliers and orders tables. Outer Join Another type of join is called an outer join. This type of join returns all rows from one table and only those rows from a secondary table where the joined fields are equal (join condition is met). For ...

SUM Function: SQL SERVER

The SUM function returns the summed value of an expression. The syntax for the SUM function is: SELECT SUM(expression ) FROM tables WHERE predicates; expression can be a numeric field or formula. Simple Example For example, you might wish to know how the combined total salary of all employees whose salary is above $25,000 / year. SELECT SUM(salary) as "Total Salary" FROM employees WHERE salary > 25000; In this example, we've aliased the sum(salary) field as "Total Salary". As a result, "Total Salary" will display as the field name when the result set is returned. Example using DISTINCT You can use the DISTINCT clause within the SUM function. For example, the SQL statement below returns the combined total salary of unique salary values where the salary is above $25,000 / year. SELECT SUM(DISTINCT salary) as "Total Salary" FROM employees WHERE salary > 25000; If there were two salaries of $30,000/year, only one ...

Use ungroup Columns in Select Query using Group By Clause:SQL SERVER

hi, I have face a problem many times to build some complex reports in crystal report that need some  group by column and also have some ungroup columns. For example, let i have a table of that structure in which i want to group data according to Areacode,AreaName,AreaRank and also want to sum of TeamCollection with other fields also such as LocalAreaCode ,LocalAreaRank, and there is one condition for having only those reords which have CollectionPer >=100 for each areacode and arearank=9 and creatdate= '11/14/2009' . Here is sql query that provide me corect data. SELECT     a.AreaCode, a.AreaName, a.AreaRank, a.CreatDate, a.LocalAreaCode, a.LocalAreaRank, a.SelfCollection, a.TeamCollection, a.CreatDate AS CreatDate , a.CollectionPer FROM         tbl_AreaCollection AS a INNER JOIN (SELECT DISTINCT AreaCode FROM          tbl_AreaCollection GROUP BY AreaCode HAVING ...

AJAX Control Toolkit Release for ASP.Net 2.0

Hi all,i found that link for asp.net 2.0 ajax latest support. So if you are working on asp.net 2.0 using ajax then you can ajax tool kit from this link. http://ajaxcontroltoolkit.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=11121 AjaxControlToolkit.zip is the full release package with complete source code to all controls, the test framework, VSI, and more. AjaxControlToolkit-NoSource.zip contains only the sample web site and VSI and is for people who don't need or want the source code for the controls

Delete Duplicate Records Rows :SQL SERVER

Following code is useful to delete duplicate records. The table must have identity column, which will be used to identify the duplicate records. Table in example is has ID as Identity Column and Columns which have duplicate data are DuplicateColumn1, DuplicateColumn2 and DuplicateColumn3. DELETE FROM MyTable WHERE ID NOT IN ( SELECT MAX ( ID ) FROM MyTable GROUP BY DuplicateColumn1 , DuplicateColumn2 , DuplicateColumn2 )

Get Country Name Through IP Address

There are situations where we have to track visitors. The tracking might include the country from the visitor has browsed the website. These statistics are often important. The major advantage of this method is a single DLL. It does not require any database setup etc. You just need to add reference to the IpToCountryLib DLL provided in the solution. To resolve the country name, the library API to be used is "GetCountry". GetCountry takes in a string parameter which is the IP Address and returns the country name as the out parameter. This is the code of the function, C# public bool GetCountry(string userHostIpAddress, out string countryName) { bool result = false; countryName = string.Empty; if (string.IsNullOrEmpty(userHostIpAddress)) return false; IPAddress ipAddress; if (IPAddress.TryParse(userHostIpAddress, out ipAddress)) { countryName = ipAddress.Country(); result = true; } return result; } To use the function you will do a call like this, C#, string country; GetCountry(...

Managing State with ASP.NET and C#

Web Applications are disconnected in nature which means that there is no way for the browser to know who is using the application at present time. In classic Asp programming maintaining state was a headache for the developers. They had to write alot of code to maintain state. But Asp.net model provides easy state management. In this article we will see how we can persist state in multiple pages so the user is recognized by the browser. Preserving State in Web ApplicationsThere are number of ways that you can use to preserve the State of the Web Application. Here are some of the possible ways listed. 1) Using Cookies (Client Side State Management technique) 2) Using Session States 3) Using Application States 4) Using HttpContext collection 5) Using ViewState (Client Side State Management technique) These are only some ways of storing the state of the user as well as the application. In this article we will see few of them in detail.

has not been pre-compiled and cannot be requested : Asp.Net

 I had created an application that used the ReportViewer, and of course it worked fine on development. But once published, I too got the error that said "... The file has not been pre-compiled, and cannot be requested." As usual, a not very helpful error message and is confusing. Issue: The server I was publishing to did not have the Microsoft.ReportViewer.Webforms.dll in the bin folder (or any Crystal Report dlls). These do not get published over with your application, they are stored and referenced differently. Solution: 1) one solution is to find the .dll on your development server and manually add it to the bin of your application. This works, but only for that application. And if you have more than one application using Crystal Reports (ReportViewer), then you'd have to manually do this for each application you publish. 2) a more efficient fix is to install the Crystal Web Components (make sure the version is the same you are developing with.. i.e. Crystal Repor...