Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello?? :) :confused:

can some body tell where i can find a video tutorial or how i can view a store procedure on to a web page using asp.net mvc2? (result view)
its bin killing me all week.

can somebody help me please I'm new at this.

thank you,
Posted
Updated 7-Mar-11 14:14pm
v2
Comments
Albin Abel 7-Mar-11 21:23pm    
If you know how to use sql from model then the same way you can use stored procedure. Use the command type stored procedure. Post your code spinets, will try to help if anything wrong in it
SabirB 21-Apr-11 4:34am    
Hey did you find out the solution?
Even i am also struggling on that as i am new to MVC2....
Guys please let me know if any body have implemented the same...

Thank you Very much.

Sabir,
Centurion,SouthAfrica.

If your using a ORM like Entity Framework you can call the list of items in your Controller like this.

//these are the parameters that will pass into a storedprocedure
C#
public ActionResult SearchList()
                                   {

                                      var model = new Models.SearchBy();
                                      model.para1 = 0;
                                      model.para2 = 0;
                                      model.para3 = DateTime.Today;
                                      model.para4 = DateTime.Today;


           
                                         return View(model);
                                    }


//and then call the list passing the parameters into it the stored procedure

MIDL
public ActionResult List(Models.SearchBy dr)
{
   listEntities n = new  listEntities();
   var model = n.Get_Gamelist(dr.para1, dr.para2,dr.para3,dr.para4);/*but put them in the right place*/
   return View(model);
 }


i hoop this was helpful.
 
Share this answer
 
Comments
SabirB 21-Apr-11 8:40am    
Hi Thanks for information
but my issue is some thing different which i have described below in steps.
1. created a ADO.Net Entity Data Model in Models(MVC2 - Architecture) by name Entites.edmx
2.configured database connectivity by selecting Generate from database.
3. selected all tables, views and Stored procuders from db(SQL2008)
4.finally i got two files added to my Models one is -Entites.edmx and other Entites.Designer.cs.
5. And i got all the tables in Entites.edmx
6.And all the tables, views in well described way with column name and data types which is good in Entites.Designer.cs class.
7.in my controller class added the namespace of Models and created a private object of models to controller class.
8.when i type model object.,then i am getting all the tables and views name.

9.But i am not getting the storedprocedures name which i need to bind the grid???????

I hope i described in well method.

please answer me if anybody has implemented earlier.

Thanks,
Sabir
Herfst 21-Apr-11 9:14am    
so the issue is that you want to get the storedprocedure from Entites.edmx?
you can do it in the same way as the example, but in your situation the Entites.edmx and Entites.Designer.cs. Just look at the designer.cs. and look what the name is for your ENTITIES. mine was ListEntities.
(just copy and replace that name)
Herfst 21-Apr-11 9:44am    
oh sorry about that you have to add a funtion import of your storedprocedure first. follow these steps. go to Entities.emdx-> right click on a empty space -> choose model browser-> and in your model browser go to one of your storedprocedures-> right click on it -> Function import -> and choose complex type.
then you can call it from your controller.
SabirB 21-Apr-11 11:17am    
Thank you very much.i ll follow the way you described.
SabirB 28-Apr-11 6:51am    
Thanks,
Now i got my storedprocedure and now i need to bind with a dropdownlist in one of my .aspx page.

and i did the coding like added a view but after i got this error.

The model item passed into the dictionary is of type 'System.Data.Objects.ObjectResult`1[SIMSaverMVC2.Models.getSalesRep_Result]', but this dictionary requires a model item of type 'SIMSaverMVC2.Models.getSalesRep_Result'.

Please let me know Urgent.

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900