Solved

Developing an ASP.net  MVC solution

Posted on 2013-11-11
3
646 Views
Last Modified: 2013-11-22
I am pretty new to developing application in MVC. I am primarily a VB developer and trying to learn C#.

Here is what I already have completed.

I have a website with strongly typed datasets that are used to fetch data from the backend SQL db.

Now I want to create JSON responses to some of my functions. I heard the way to go is MVC.

Can anyone show me a way out with some sample. I can provide the connection string to my  SQL db.

for eg. I have a member registration table in my database. I have 2 methods namely retrieveMemberList and retrieveMemberDetails(iMemberID)

Now I want to create a JSON response that would provide the data of the members when we pass the memberid.

the url is http://localhost/demo.svc/retrieveMemberDetails?id=1

the output needs to be {"<method_name>":[{"MEMBER_ID":"123","MEMBER_FULL_NAME":"Sam"}]}

Thank in advance for your help.
0
Comment
Question by:DevLearner
  • 2
3 Comments
 
LVL 9

Expert Comment

by:sevensnake77
ID: 39640736
You can do this 2 ways either with a stored procedure or a model of your entities.
Add a model to your database. The DBcontext will be created automatically.

You can call the model within your controller.
 public ActionResult GetDataForInvoiceNumber(DisputeKeyData disputeKeyData)  
  {  
     //Blah!  
     //....  
     return Json(disputeKeyData, JsonRequestBehavior.AllowGet);  
  }  

Open in new window

the return Json you can use firebug to see if you are recieving the data or not. Once you see you have receive it you can then use json jquery to pass it to the view.
0
 

Author Comment

by:DevLearner
ID: 39642747
I do have strongly typed dataset that were originial used for the ASP.net website. Inorder for me to directly access the SQL stored procedures how do i do so. ANy code snippet or any tutorial that describes the same.

Can you also elaborate on the "Add a model to your database" and how the DBContent is created.

A very simple code project may help me to follow through. Greatly appreciate your responses sir.
0
 
LVL 9

Accepted Solution

by:
sevensnake77 earned 500 total points
ID: 39646416
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Technology Resume 7 66
Query in AngularJS 8 42
how to pass the "this" object from C# to a Java Script function. 2 28
"lblTime is not declared" 3 28
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question