开发者

Insert posted data in SQL Server Database

开发者 https://www.devze.com 2023-03-13 09:16 出处:网络
I am able to post the data from Excel to ASP.NET MVC web service. Here is My code for that: Sub SendData()

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

精彩评论

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