Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @using MySql.Data.MySqlClient;
- @using System.Configuration;
- @{
- Layout = "~/_Layout.cshtml";
- // weiterer C# Code hier
- Page.Title = "E-Mensa";
- string conString = ConfigurationManager.ConnectionStrings["dbConStr"].ConnectionString;
- MySqlConnection con = new MySqlConnection(conString);
- con.Open();
- MySqlCommand cmd;
- try
- {
- cmd = con.CreateCommand();
- cmd.CommandText = "SELECT * FROM zutaten";
- MySqlDataReader r = cmd.ExecuteReader();
- <table>
- <tr>
- <th>Zutat</th>
- <th>Vegan?</th>
- <th>Vegetarisch?</th>
- <th>Glutenfrei?</th>
- </tr>
- @while (r.Read())
- {
- <tr>
- <td>
- @r["Name"]
- </td>
- <td>
- @{ var yikes = 1;}
- @if (@*r["Vegan"] == 1*@ yikes == 1)
- {
- @:<i class="fas fa-check"></i>
- }
- else
- {
- @:<i class="fas fa-times"></i>
- }
- </td>
- <td>
- @if (@*r["Vegetarisch"] == 1*@ yikes == 0){
- @:<i class="fas fa-check"></i>
- }
- else{
- @:<i class="fas fa-times"></i>
- }
- </td>
- <td>
- @if (@*r["Glutenfrei"] == 1*@ yikes == 1)
- {
- @:<i class="fas fa-check"></i>
- }
- else
- {
- @:<i class="fas fa-times"></i>
- }
- </td>
- </tr>
- }
- @*r.Close();*@
- </table>
- }
- catch (Exception e)
- {
- //throw new Exception();
- <li>
- <p class="error">Das hat nicht geklappt.</p>
- <pre>@e.Message</pre>
- </li>
- }
- con.Close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement