Tuesday 6 September 2016

SESSION Variables are stored on the server,



SESSION Variables are stored on the server, can hold any type of data including references, they are similar to global variables in a windows application and use HTTP cookies to store a key with which to locate user's session variables.
VIEWSTATE Variables are stored in the browser (not as cookies) but in a hidden field in the browser. Also Viewstate can hold only string data or serializable objects.

Web Applications are natively statesless, means once a web page renders from server to client, nothing remains on server and the next time user submits the page you have to create the page again.
Solutions in ASP.NET
ASP.NET provides multiple simple solutions to this problems like:
1- Viewstate
2- Session Variables
3- Application Variables
4- Cache
5- Cookies

https://www.youtube.com/watch?v=TmHILJhJfFo
https://www.youtube.com/watch?v=odxU3L1OB-M

SQl server-Dynamic query for extracting data pass parameter as table,col,condition,id



create function udf_GetActorname(@ID varchar(10),@Colname varchar(50),@Con_Col varchar(100),@tabName varchar(100))
 returns varchar(100)
 As
 begin
 declare @QueryResult varchar(max)
 set  @QueryResult='select '+@Colname+' from '+@tabName+' where '+@Con_Col+'='+cast(@ID as varchar(10))+''
 return @QueryResult
 end
 declare @id varchar(10)
 declare @Colname varchar(50)
 declare @Con_Col varchar(50)
 declare @tabName varchar(50)
  set @id='1'
  set @Colname='ActorName'
  set @Con_Col='actorid'
  set @tabName='actor'
  
  declare @QueryResult nvarchar(max)
  --set @QueryResult =dbo.udf_GetActorname(@id,@Colname,@Con_Col,@tabName)
  set @QueryResult =dbo.udf_GetActorName('1','ActorName','Actorid','Actor')
  print @QueryResult
  exec sp_executesql @QueryResult
  select ActorName from actor where actorid=1
https://www.youtube.com/watch?v=TmHILJhJfFo
https://www.youtube.com/watch?v=odxU3L1OB-M

Difference between stored procedure and function



Difference between stored procedure and function
 1) Procedure can return zero or n values whereas function can return one value which is mandatory.
 2) Procedures can have input, output parameters for it whereas functions can have only input parameters.
 3) Procedure allows select as well as DML statement in it whereas function allows only select statement in it.
 4) Functions can be called from procedure whereas procedures cannot be called from function.
 5) Exception can be handled by try-catch block in a procedure whereas try-catch block cannot be used in a function.
 6) We can go for transaction management in procedure whereas we can't go in function.
 7) Procedures cannot be utilized in a select statement whereas function can be embedded in a select statement.

Difference between Abstract and Interface

Abstract Class:

-Abstract class provides a set of rules to implement next class
 -Rules will be provided through abstract methods
 -Abstract method does not contain any definition
 -While inheriting abstract class all abstract methods must be override
 -If a class contains at least one abstract method then it must be declared as an “Abstract Class”
 -Abstract classes cannot be instantiated (i.e. we cannot create objects), but a reference can be created
 -Reference depends on child class object’s memory
 -Abstract classes are also called as “Partial abstract classes”
 -Partial abstract class may contain functions with body and functions without body
 -If a class contains all functions without body then it is called as “Fully Abstract Class” (Interface)

Interface:

-If a class contains all abstract methods then that class is known as “Interface”
 -Interfaces support like multiple inheritance
 -In interface all methods r public abstract by default
 -Interfaces r implementable
 -Interfaces cannot be instantiated, but a reference can be created
What are differences between Array list and Hash table?

Ans: 1) Hash table store data as name, value pair. While in array only value is store.

2) To access value from hash table, you need to pass name. While in array, to access value, you need to pass index number.

3) you can store different type of data in hash table, say int, string etc. while in array you can store only similar type of data.

What are differences between system.stringbuilder and system.string?

The main difference is system.string is immutable and system.stringbuilder is a mutable. Append keyword is used in string builder but not in system.string.

Immutable means once we created we cannot modified. Suppose if we want give new value to old value simply it will discarded the old value and it will create new instance in memory to hold the new value.

What are the differences between Application object and session object?

Ans: The session object is used to maintain the session of each user. If one user enter in to the application then they get session id if he leaves from the application then the session id is deleted. If they again enter in to the application they get different session id.
 But for application object the id is maintained for whole application.