开发者

Insert posted data in SQL Server Database

I am able to post the data from Excel to ASP.NET MVC web service. Here is My code for that:

Sub SendData()
Dim HttpReq As Object, url As String
Set HttpReq = CreateObject("MSXML2.ServerXMLHTTP"开发者_高级运维)
url = "http://localhost:11121/Student/PostData/"
HttpReq.Open "POST", url, False
HttpReq.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
HttpReq.Send "Student=jsmith112"
Debug.Print HttpReq.ResponseText
End Sub

Now, I Want to have a ControllerAction "Insert" That will Insert this posted data in SQLServer Database.

What do I need to do to controller action for this?


You need to add <AcceptVerbs(HttpVerbs.POST)> attribute if it's vs2008 or just <HttpPost()> for vs2010 to your controller method, so it receives the posted data. Please note that this is in C#, syntax is slightly different for VB.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜