views:

186

answers:

3

I am an asp.net webforms developer and new to asp.net MVC....

Is it possible to use SQL Server 2005 stored procedures in asp.net MVC?? If so can any one help me....

+2  A: 

Using stored procedures is not directly related to which type of application you are building. You could use the same type of data access code as you are used to from WebForms, such as ADO.NET (SqlConnection, SqlCommand etc.).

Anders Fjeldstad
+5  A: 

This is absolutely possible. Although it claims to be a Model View Controller framework, ASP.NET MVC is really just View Controller, it's up to you the developer to decide and implement a model persistence layer.

As a WebForms developer you're likely familiar with DataSets, however these are usually avoided in an ASP.NET MVC application in favour of an ORM framework like NHibernate or Linq2Sql, both of which have plenty of resources online for integration with ASP.NET MVC. As a good starting point, you might want to look at S#arp Architecture which is a good example of a best practice MVC stack.

roryf
@Rory:Can you give a sample code or functionality to use sql server stored procedures in MVC
bala3569
How you call stored procedures depends on the persistence framework you choose. Once you've picked one I suggest you have a look at the documentation and post new questions if you still need help.
roryf
A: 

Absolutely agree with answers above, my advice is to use Entity framework or LINQ2SQL and simply import stored procedure as function which you can use as dbContext.Somemehto();

Stored procedure should only be linked with Model that is pure sever code, so there is no difference in using it from Desktop application or from Model. If it is not distributed database.

SonOfOmer