Solved

Developing an ASP.net  MVC solution

Posted on 2013-11-11
3
645 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

839 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