This not so much a datatables question other than it is in a asp.net mvc project that has datatables in it. I am having the user import a text file into a datatable: https://editor.datatables.net/examples/extensions/import
After it is imported and they have reviewed the data, I need the user to click a button to call a stored procedure. The stored procedure is parsing the data and putting into another table, which is the datasource for another datatable. But the stored procedure itself does not return any data. From what I am researching, since datatables uses MVC i need to put that call in a controller.
public class ParseImportDataController: ApiController
{
[HttpGet]
[HttpPost]
public IHttpActionResult cleanAndImport()
{
var request = HttpContext.Current.Request;
var settings = Properties.Settings.Default;
string AsOfCookie = request.Cookies.Get("AsOfDate").Value;
string strCon = settings.DbConnection;
SqlConnection DbConnection = new SqlConnection(strCon);
DbConnection.Open();
SqlCommand command = new SqlCommand("sp_ImportFTE", DbConnection);
command.CommandType = System.Data.CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("@EffectiveDate", AsOfCookie));
command.ExecuteNonQuery();
DbConnection.Close();
return Ok(1); //no idea what to return
}
}
I can't find out how I have the button click call this code in the controller. Can I use Buttons to add a custom button that will call the cleanAndImport function?
I have no idea if the code in the controller is correct, but I figure that will be the next struggle.
Any help would be greatly appreciated.