I have 5 files in Excel. I want to change at one time the Data Source in Connection String using MVC.
In my controller:
public ActionResult ChangeExcelConnection()
{
ViewBag.Message = "Change connection.";
return View();
}
In ChangeExcelConnection.cshtml I want to enter name of data source.
@using System.Web.Mvc;
@{
ViewBag.Title = "ChangeExcelConnection";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>@ViewBag.Message</h2>
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
<div class="editor-label">Enter the name of the data source:</div>
<div class="editor-field">
@Html.TextArea("source")
</div><br>
<p>
<input type="submit" value="Save changes" />
</p>
</fieldset>
}
And I don't know how to change in controller files properties.
[HttpPost]
public ActionResult ChangeExcelConnection(String source)
{
DirectoryInfo directory = new DirectoryInfo(Server.MapPath("~/Excels"));
var filesListing = directory.GetFiles("*.xlsm", SearchOption.AllDirectories);
//???
}
Do you have any idea how to do this and it is possible at all?
With regards,
Monica