I can't find any updated answers that work with Visual Studio 2017. I've been stuck for over a day trying to figure it out and every guide I find online is either extremely dated or anything that I try to apply to my code give me errors I can't fix. I am using C#, HTML5, ASP.NET MVC5, and VS2017
First off I have my controller which connects to the SQL Server database with:
public void GetStoredProc()
{
Exclusion objExclusion = new Exclusion();
string StrConnectionString = ConfigurationManager.ConnectionStrings["EligibilityContext"].ConnectionString;
SqlConnection sqlConnection1 = new SqlConnection(StrConnectionString);
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "[advantage].[GetAdvantageEligibilityDataOverride]";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = sqlConnection1;
sqlConnection1.Open();
SqlDataReader reader = cmd.ExecuteReader();
if (reader.HasRows)
{
int count = reader.FieldCount;
while (reader.Read())
{
if (count > 3)
{
int IntNum;
int.TryParse(reader.GetValue(0).ToString(), out IntNum);
objExclusion.PolicyNo = IntNum;
objExclusion.PolicyMod = (reader.GetValue(1).ToString());
objExclusion.InsuredName = (reader.GetValue(2).ToString());
objExclusion.ClientID = IntNum;
//Console.WriteLine(reader.GetValue(i));
}
}
}
// Data is accessible through the DataReader object here.
sqlConnection1.Close();
}
Here is my index.html
page. I know there needs to be code added here in order to display the web page but I'm a programming noob and am at a loss for what exactly to put.
@model IEnumerable<Advantage_Exclusions_Eligibility.Models.Exclusion>
@{
ViewBag.Title = "Index";
}
<h2>AEE List</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<p>
</p>
<div>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.PolicyNo)
</th>
<th>
@Html.DisplayNameFor(model => model.PolicyMod)
</th>
<th>
@Html.DisplayNameFor(model => model.InsuredName)
</th>
<th>
@Html.DisplayNameFor(model => model.ClientID)
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.PolicyNo)
</td>
<td>
@Html.DisplayFor(modelItem => item.PolicyMod)
</td>
<td>
@Html.DisplayFor(modelItem => item.InsuredName)
</td>
<td>
@Html.DisplayFor(modelItem => item.ClientID)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.PolicyNo }) |
@Html.ActionLink("Details", "Details", new { id=item.PolicyNo }) |
@Html.ActionLink("Delete", "Delete", new { id=item.PolicyNo })
</td>
</tr>
}
</table>
<div class="pagination">
<nav id="AEEPagination" aria-label="Page navigation"
style="display:none;">
<ul class="pagination pagination-sm"></ul>
</nav>
</div>
</div>
Any and all help would be greatly appreciated!