Saturday, November 24, 2012

How to Create ASMX web Service in ASP.NET 4.0

Asmx Web Services are easy and simple to Create and use. This tutorial guides you how to write a ASMX Web Service step by step. 
  • Open Visual studio and create new Website. 
  • Right Click on Website and Click on 'Add New Item'.
asp.net asmx web service
  • A New Window will Open, select 'Web Service' , name it and click 'Add'.
asp.net asmx webservice
  • When you click 'Add' Button, new files ( with .asmx and .cs extensions ) will be added to Project.
  • Visual Studio will add some code in it.
  • A default Web Method named 'Helloworld' will also be added in it.
asp.net asmx Web Service
  • You have created ASMX Web Service Successfully.
  • Replace 'Helloworld' Web Method with following code.
  • This is Custom Web Method we created for our ASMX Web Service.

In next tutorial, we will learn how to use this Web Service.

Monday, July 23, 2012

Advantages of Stored Procedure in Microsoft SQL Server


There are many advantages of using stored procedures in Microsoft SQL Server. These are :
  1. Easier to maintain and troubleshoot as they are modular.
  2. Stored procedures enable better tuning for performance.
  3. While using stored procedures is much easier from a GUI end than building complex queries.
  4. Stored procedures help in reducing network usage.
  5. Stored procedures provide more scalability to an application.
  6. Reusable and hence reduce code.
  7. Stored procedures can be part of a separate layer which allows separating the concerns. Hence Database layer can be handled by separate developers proficient in database queries.


How to Code Efficient Transactions in Microsoft SQL Server

To Code efficient transactions in Microsoft SQL Server, We must take care of following things :

  1. Don't allow input from users during a transaction.
  2. Don't open transactions while browsing through data.
  3. Keep the transaction as short as possible.
  4. Use lower transaction isolation levels.
  5. Access the least amount of data possible while in a transaction.

Security Features of Stored Procedures in Microsoft SQL Server


Security features of stored procedures are available in Microsoft SQL Server. These are :
  1. Provide more granular security control through stored procedures rather than complete control on underlying data in tables.
  2. Grants users permissions to execute a stored procedure irrespective of the related tables.
  3. Grant users permission to work with a stored procedure to access a restricted set of data yet no give them permissions to update or select underlying data.
  4. Stored procedures can be granted execute permissions rather than setting permissions on data itself.


Usage of Triggers in Microsoft SQL Server


Triggers are used in Microsoft SQL Server for various purpose. These are used when :
  1. Creation of audit log of database activity.
  2. For applying business rules.
  3. For applying calculation on data from tables which is not stored in them.
  4. To enforce referential integrity.
  5. When alter data in a third party application needed.
  6. To execute SQL statements as a result of an event or condition automatically.