Use this space to put some text. Update this text in HTML

468x60 banner ad

Advertise with Us

Powered by Blogger.

Monday, 11 April 2016

unrecognized attribute targetframework note that attribute names are casesensitive



Unrecognized attribute targetFramework Note that attribute names are Case-Sensitive

I just installed Visual Studio 2010, followed by IIS in window 7. When building a website in .net framework 4.0 and convert this into application in IIS then its shows this error Unrecognized attribute targetFramework Note that attribute names are Case-Sensitive.



If i remove the targetFramework="4.0" from web config file or change targetFramework="4.0” to targetFramework="3.5" then it shows me a second error which is related to linq reference error



Solutions

First Step:

Register ASP.Net in IIS to get it resolved through commands prompt
Start-> Run-> Type cmd -> right click and past the below command or type manually.
cd /d C:\Windows\Microsoft.NET\Framework\v4.0.30319

You have to enter on the asp.net framework version 4.0.



Now Stop the iis server
In command prompt right click and past the below command or type manually.
iisreset /stop

You have to successfully stop the internet services(IIS).




Now you have to install asp.net 4.0
In command prompt right click and past the below command or type manually.
aspnet_regiis -i

You have to successfully install asp.net4.0 version.


Start the IIS Server
In command prompt right click and past the below command or type manually.
iisreset /start

You have to successfully start the internet services(IIS).



Second Step:
As you have to installed .NET framework 4.0, then create an application pool that uses .NET 4.0, and assign this application pool to your application.
Your code currently runs using .NET Framework 2.0, which does not seem to work.
Start IIS Server by typing command inetmgr on search window.



Change your Application pool setting
Click on Application Pools
Right Click on DefaultAppPool -> Set Application Pool Default....->Change .Net Version to V 4.0.






  1. Test website ->manage website->advanced setting>
  2. the first option change from classic to framework 4 integrated.





Saturday, 9 April 2016

Csharp Region


#region (C# Reference)

#region lets you specify a block of code that you can expand or collapse when using the outlining feature of the Visual Studio Code Editor.


 In longer code files, it is convenient to be able to collapse or hide one or more regions so that you can focus on the part of the file that you are currently working on.


The following example shows how to define a region:

   #region Method For Add and Substract
    private int A, B, C;
    public int SumAbcMethod()
    {
        return A + B + C;
    }
    public int SubstractAbcMethod()
    {
        return B + C;
    }
    #endregion
    #region Method For Add and Substract

    public int MultiplayAbcMethod()
    {
        return A * B * C;
    }
    public int DivideAbcMethod()
    {
        return B / C;
    }
    #endregion

Note: 


A #region block must be terminated with a #endregion directive.


A #region block cannot overlap with a #if block. However, a #region block can be nested in

 a #if block, and a #if block can be nested in a #region block.

Collapse region:






Advantage:
The method was pretty clear to understand by looking at the region names. This being said, the same method once refactored would be as clear as the original.

Disadvantage:

It wasn't obvious if there were dependencies between the regions. Hopefully, there were no reuse of variables; otherwise, the maintenance could be a nightmare even more.
The method was nearly impossible to test. How would you easily know if the method which does twenty things at a time does them correctly?




Friday, 8 April 2016

Object Reference not set to an Instance of an Object in asp.net



In the below code, You got that error because your Session["User_ID "] was null and when you try to return a string representation of that you got the object reference  not set to an instance of an object error. There is difference between .Tostring() and casting Convert.ToString().

if (!Page.IsPostBack)
{          
  ViewState["purid"] = Request.QueryString["User_ID"].ToString();
}







Solution for Object Reference not set to an Instance of an Object in ASP.NET

ToString throw null reference error but Convert.ToString() does not throw null reference error.

if (!Page.IsPostBack)
{
  ViewState["purid"] = Convert.ToString(Request.QueryString["order_no_id"]);
}






Wednesday, 6 April 2016

SQL Having Clause

Having clause is used to filter data based on the group functions. If the SQL SELECT statement does not contain aggregate functions (max, min, sum, count), you can use a SQL SELECT statement that contains a HAVING clause without a GROUP BY clause.

The HAVING clause without a GROUP BY clause acts like the WHERE clause.
If the HAVING clause does not contains aggregate functions, use the WHERE clause for faster performance.

SQL Having Syntax:

SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING aggregate_function(column_name) operator value;


SQL Having Examples:

Example1
SQL HAVING clause example that uses the SQL SUM function.
Use the SQL SUM function to return the name of the department and the total salary (in the department wise). The SQL HAVING clause will filter the results so that only departments with salary greater than 700000 (7 Lakh) will be returned.


SELECT Department, SUM(Salary) AS "Total Salary"
FROM Employee
GROUP BY Department
HAVING SUM(Salary) > 700000.00;

Query Result

 

Example2
HAVING clause with the SQL COUNT function.
Use the SQL COUNT function to return the name of the department and the number of employees (in the department wise) that make over 600000 (6 Lakh). The SQL HAVING clause will filter the results so that only departments with more than 1 employee will be returned.


SELECT Department, COUNT(*) AS "Number of employees"
FROM Employee
WHERE salary > 600000.00
GROUP BY Department
HAVING COUNT(*) > 1;

Query Result

 


Example3

HAVING clause with the SQL MIN function.
Use the SQL MIN function to return the name of each department and the minimum salary in the department. The SQL HAVING clause will return only those departments where the minimum salary is greater than 500000 (5 Lakh).


SELECT Department, MIN(Salary) AS "Lowest salary"
FROM Employee
GROUP BY Department
HAVING MIN(Salary) > 500000;

Query Result

Example4

HAVING clause with the SQL MAX function.
Use the SQL MAX function to return the name of each department and the maximum salary in the department. The SQL HAVING clause will return only those departments whose maximum salary is less than 1000000 (10 Lakh).


SELECT Department, MAX(salary) AS "Highest salary"
FROM Employee
GROUP BY Department
HAVING MAX(Salary) < 1000000;

Query Result