I have a question.
First, I need to tell you guys that I'm kind of new to programming and tried a tutorial.
Now my question is: How can I get multiple Sql tables to c#. At the moment my C# code is only reading from one table. But I need information of more tables.
At the moment I'm only getting the information from the table: "Domeinnaam" Now I also need to get the information from the tables: X & Y.
How should I do this?
My code:
Controller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DNDB.Models;
using System.Data.SqlClient;
namespace DNDB.Controllers
{
public class DomeinnaamController : Controller
{
// GET: Domeinnaam
public ActionResult Index()
{
var entities = new DomeinnaambeheerEntities1();
return View(entities.Domeinnaam.ToList());
}
public ActionResult CreateDomainName()
{
return View();
}
The automatic generated page:
@model IEnumerable<DNDB.Models.Domeinnaam>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.IsActief)
</td>
<td>
@Html.DisplayFor(modelItem => item.Naam)
</td>
<td>
@Html.DisplayFor(modelItem => item.TLD)
</td>
<td>
@Html.DisplayFor(modelItem => item.DatumRegistratie)
</td>
<td>
@Html.DisplayFor(modelItem => item.Omschrijving)
</td>
<td>
@Html.DisplayFor(modelItem => item.DatumOpzeg)
</td>
<td>
@Html.DisplayFor(modelItem => item.EigenaarID)
</td>
<td>
@Html.DisplayFor(modelItem => item.Opmerking)
</td>
<td>
@Html.DisplayFor(modelItem => item.BeheerAccountID)
</td>
<td>
@Html.DisplayFor(modelItem => item.KlantID)
</td>
<td>
@Html.DisplayFor(modelItem => item.RegistrarID)
</td>
<td>
@Html.DisplayFor(modelItem => item.BetaaldVan)
</td>
<td>
@Html.DisplayFor(modelItem => item.BetaaldTot)
</td>
<td>
@Html.DisplayFor(modelItem => item.AfspraakPrijs)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.ID })
@Html.ActionLink("Details", "Details", new { id = item.ID })
@Html.ActionLink("Delete", "Delete", new { id = item.ID })
</td>
</tr>
}
Createdomeinnaam.cshtml
@model DNDB.Models.Domeinnaam
@Styles.Render("~/Content/StyleSheet.css")
@{
ViewBag.Title = "CreateDomainName";
}
@using (Html.BeginForm())
{
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>CreateDomainName</title>
</head>
<body>
<label>IsActief</label>
@Html.CheckBoxFor(m => m.IsActief)
<label>Naam</label>
@Html.TextBoxFor(m => m.Naam)
<label>TLD</label><br />
@Html.TextBoxFor(m => m.TLD)
<label>DatumRegistratie</label><br />
@Html.TextBoxFor(m => m.DatumRegistratie)
<label>Omschrijving</label><br />
@Html.TextBoxFor(m => m.Omschrijving)
<label>OpzegDatum</label><br />
@Html.TextBoxFor(m => m.DatumOpzeg)
<label>EigenaarID</label><br />
@Html.TextBoxFor(m => m.EigenaarID)
<label>Opmerking</label><br />
@Html.TextBoxFor(m => m.Opmerking)
<label>BeheerAccountID</label><br />
@Html.TextBoxFor(m => m.BeheerAccountID)
<label>KlantID</label><br />
@Html.TextBoxFor(m => m.KlantID)
<label>RegistrarID</label><br />
@Html.TextBoxFor(m => m.RegistrarID)
<label>BetaaldVan</label><br />
@Html.TextBoxFor(m => m.BetaaldVan)
<label>BetaaldTot</label><br />
@Html.TextBoxFor(m => m.BetaaldTot)
<label>Prijsafspraak</label><br />
@Html.TextBoxFor(m => m.AfspraakPrijs)
<br />
</body>
</html>
<input type="submit" value="add">
}
Sorry if my question is not 100% clear. The explenation is also a bit hard for me because I do not understand everything of programming. Please tell me when you need clarification.
EDIT: A code example would be amazing.
Thanks alot guys.