How can I insert posted data into the database?

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?

  • Answer:

    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.

user793468 at Stack Overflow Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.