开发者

Plain text connection to SQL Server 2005

If I did not want to create SqlConnection and SqlCommand objects etc etc but instead wanted to use only System.Net.WebClient (or some other "essentially plain text" communication) to talk to a SQL Server 2005 or above data开发者_开发问答base, how would I go about connecting, issuing commands and receiving result sets?

I'm assuming I'll need to do a lot of parsing of data to get the structure I'm used to, but how would you go about a "bare-bones" SQL connection?


I recommend you go over Creating an OData API for StackOverflow including XML and JSON in 30 minutes to get a feel of how to add an OData layer to your application.

SqlClient (ie. SqlConnection and SqlCommand) is the bare-bones SQL connection objects. They're the lowest API that offers access to the TDS connections and there is nothing lower than that. Anything bellow this level would mean you'd have to write your own TDS implementation.

There is an alternative way of communicating with SQL Server, namely via HTTP SOAP services, see Overview of Native XML Web Services for Microsoft SQL Server 2005. However, this is a deprecated feature and it doesn't give you any advantage.

If you want your client to communicate via plain HTTP with a SQL Server, you should place a web service layer to act as a communication mid-tier. Your client would talk to this layer using SOAP or REST, and this layer would talk to SQL in turn using TDS. Luckly there is a way to achieve this with just a few lines of code and a couple of clicks, by deploying an OData service.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜