title: Save and Display Image from DataBase
body: <p>Not sure if this is close or not. 
  I'm creating an image field within the database table Events using the code</p>
  
  <pre><code>public string EvtImage { get; set; }
  </code></pre>
  
  <p>For a start I'm not even sure if it should be a string. 
  I am then trying to add the Image to the database by using the code</p>
  
  <pre><code>SqlCommand cmd = new SqlCommand("insert into Events (AspNetUsersId,EvtName,EvtType,EvtDescription,EvtDate,EvtVote, EvtImage) values (@AspNetUsersId, @EvtName, @EvtType, @EvtDescription, @EvtDate, @EvtVote, @EvtImage)");
  
  cmd.Parameters.AddWithValue("@AspNetUsersId", userId);
  cmd.Parameters.AddWithValue("@EvtName", eventName.Text);
  cmd.Parameters.AddWithValue("@EvtType", eventType.Text);
  cmd.Parameters.AddWithValue("@EvtDescription", eventDescription.Text);
  cmd.Parameters.AddWithValue("@EvtDate", datetimepicker.Value);
  cmd.Parameters.AddWithValue("@EvtVote", 0);
  
  if (eventImage.HasFile)
  {
      var  imagename = eventImage.FileName;
      cmd.Parameters.AddWithValue("@EvtImage", imagename);
  }
  
  loadDatabase(cmd);
  </code></pre>
  
  <p>And once this is added I'm trying to display it within a <code>Repeater</code> in ASP.NET using the code</p>
  
  <pre><code>&lt;asp:Repeater runat="server" ID="repeaterEvent"&gt;
      &lt;ItemTemplate&gt;
          &lt;div class="jumbotron"&gt;
  
              &lt;h2&gt;&lt;asp:Label ID="lblEventTest" runat="server" Text='&lt;%#Bind("EvtName") %&gt;'&gt;&lt;/asp:Label&gt;&lt;/h2&gt;
              &lt;h3&gt;&lt;asp:Label ID="Label1" runat="server" Text='&lt;%#Bind("EvtType") %&gt;'&gt;&lt;/asp:Label&gt;&lt;/h3&gt;
              &lt;h4&gt;&lt;asp:Label ID="Label3" runat="server" Text='&lt;%#Bind("EvtDate") %&gt;'&gt;&lt;/asp:Label&gt;&lt;/h4&gt;
              &lt;h4&gt;&lt;asp:Label ID="Label2" runat="server" Text='&lt;%#Bind("EvtDescription") %&gt;'&gt;&lt;/asp:Label&gt;&lt;/h4&gt;   
              &lt;h4&gt;&lt;asp:Label runat="server"&gt;Amount Attending: &lt;/asp:Label&gt;
                  &lt;asp:Image ID="label6" runat="server" ImageUrl='&lt;%#Bind("EvtImage") %&gt;' /&gt;
              &lt;asp:Label ID="Label4" runat="server" Text='&lt;%#Bind("EvtVote") %&gt;'&gt;&lt;/asp:Label&gt;&lt;/h4&gt;
              &lt;asp:Button runat="server" ID="eventButtonTest" Text="Attending" class="btn btn-primary" OnClick="EventVote_Click"/&gt;
          &lt;/div&gt;
      &lt;/ItemTemplate&gt;
  &lt;/asp:Repeater&gt;
  </code></pre>
  
  <p>I am creating the <code>Repeater</code> by using the code:</p>
  
  <pre><code>SqlConnection conn = new SqlConnection(@"Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-StudentMoneySaver-20160203040444.mdf;Initial Catalog=aspnet-StudentMoneySaver-20160203040444;Integrated Security=True");
  
  string query;
  SqlCommand SqlCommand;
  SqlDataReader reader;
  
  SqlDataAdapter adapter = new SqlDataAdapter();
  //Open the connection to db
  conn.Open();
  
  //Generating the query to fetch the contact details
  query = "SELECT EvtName, EvtType, EvtDescription, EvtDate, EvtVote, EvtImage FROM Events";
  SqlCommand = new SqlCommand(query, conn);
  adapter.SelectCommand = new SqlCommand(query, conn);
  //execute the query
  reader = SqlCommand.ExecuteReader();
  //Assign the results 
  repeaterEvent.DataSource = reader;
  //Bind the data
  repeaterEvent.DataBind();
  </code></pre>