如何在ASP.NET C#中创建连接到MS SQL数据库并从数据库中检索存储过程值的JSON restful webservice? [英] How to create a JSON restful webservice in ASP.NET C# that connect to MS SQL Database and retrieve stored procedures values from the database?

查看:128
本文介绍了如何在ASP.NET C#中创建连接到MS SQL数据库并从数据库中检索存储过程值的JSON restful webservice?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在ASP.NET C#中创建连接到MS SQL数据库并从数据库中检索存储过程值的JSON restful webservice?我的项目中提供了所有存储过程,数据访问层和业务层。但我不知道如何创建宁静的Web服务以及如何调用存储过程值。



此Web服务最终将用于与iPhone SDK进行通信。此Web服务的结果将显示在iPhone应用程序中。这个iPhone应用程序将安装在iphone上,它将与web服务进行交互以获取数据库值。



任何帮助都将不胜感激。



谢谢!

How to create a JSON restful webservice in ASP.NET C# that connect to MS SQL Database and retrieve stored procedures values from the database?. I have all stored procedures, data access layers and business layer available in my project. But I do not know how to create restful web service and how to call stored procedures values.

This webservice will eventually be used to communicate with iPhone SDK. And results of this web service will be shown in iPhone application. This iPhone application will be installed on iphone , and it will interact web service to get database values.

Any help would be appreciated.

Thanks!

推荐答案

使用.Net Framework 3.5或更高版本,您可以开发基于 REST 的服务。您可以参考以下链接获取更多相关信息。



http://msdn.microsoft.com/en-us/library/dd203052.aspx



http://msdn.microsoft.com/en-us/netframework/dd547388



http://msdn.microsoft.com/en-us/netframework/cc950529



JSON 和WCF REST服务。



http://dotnetninja.wordpress.com/2008/05/02/rest-service-with -wcf-and-json /



http://debugmode.net/2011/05/15/wcf-rest-service-with-josn-data/



但是,要开发REST服务,WCF支持不是强制性的,您即使使用简单的 HttpHandler HttpModule 也可以开发REST服务。



使用C#开发REST Web服务 - 演练



要调用SQL Server存储过程,您可以使用Ado.Net。



http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson07.aspx
Using .Net Framework 3.5 or above you can develop REST based Service. You may refer below links for more information on this.

http://msdn.microsoft.com/en-us/library/dd203052.aspx

http://msdn.microsoft.com/en-us/netframework/dd547388

http://msdn.microsoft.com/en-us/netframework/cc950529

For JSON and WCF REST Services.

http://dotnetninja.wordpress.com/2008/05/02/rest-service-with-wcf-and-json/

http://debugmode.net/2011/05/15/wcf-rest-service-with-josn-data/

However to develop REST Service, WCF support is not obligatory, you can develop REST Service even using simple HttpHandler or HttpModule.

Developing a REST Web Service using C# - A walkthrough

To call your SQL Server Stored Procedure you may use Ado.Net.

http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson07.aspx


用于与使用restful web服务的iphone通信json作为数据,最好的库是restkit:



https:// github。 com / RestKit / RestKit [ ^ ]
For communicating iphone with restful web service which uses json as data, the best library is restkit:

https://github.com/RestKit/RestKit[^]


这是一个非常好的演练,从头开始创建您的第一个JSON Web服务,从SQL Server加载和保存数据, d甚至使用JavaScript或在iPhone上显示它:





[创建一个JSON Web服务]



我认为这几乎涵盖了你要求的一切!!!
Here's a pretty good walkthrough of creating your first JSON web service from scratch, loading and saving data from SQL Server, and even displaying it using JavaScript or on an iPhone:


[Creating a JSON Web Service]

I think that pretty much covers everything you were asking for !!!


这篇关于如何在ASP.NET C#中创建连接到MS SQL数据库并从数据库中检索存储过程值的JSON restful webservice?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆