title: asp.net insert a specific image into database from code behind
body: <p>I would like to insert a specific image into the database when a specific value is selected in a dropdownlist. I would to use a switch statement to insert different image depending on the value selected.</p>
  
  <p>here is my code so far:</p>
  
  <pre><code>  protected void ButtonSkicka_Click(object sender, EventArgs e)
      {
          try
          {
              Conn.Open();
              SqlCommand Cmd = new SqlCommand("insert into NorrgårdsvägenKomm (Namn, Kommentar, DateTime, Tag) values (@Namn, @Kommentar, @DateTime, @Tag)", Conn);
              Cmd.Parameters.AddWithValue("@Namn", TextBoxNamn.Text);
              Cmd.Parameters.AddWithValue("@Kommentar", TextBoxMedd.Text);
              Cmd.Parameters.AddWithValue("@DateTime", System.DateTime.Today.ToShortDateString());
              Cmd.Parameters.AddWithValue("@Tag", DropDownList1.SelectedItem.ToString());
              Cmd.ExecuteNonQuery();
              Conn.Close();
  
              string Value;
              Value = DropDownList1.SelectedItem.Text;
  
              switch (Value)
              {
                  case "Högprio":
                      Conn.Open();
                      SqlCommand Cmd1 = new SqlCommand("insert into NorrgårdsvägenKomm (VarningsBild) values (@VarningsBild)", Conn);
                      Cmd1.Parameters.AddWithValue("@VarningsBild", "Images/Högprio.png/");
                      Cmd1.ExecuteNonQuery();
                      Conn.Close();
                      break;
              }
  
              TextBoxNamn.Text = "";
              TextBoxMedd.Text = "";
  
              Response.Redirect("Norrgårdsvägen.aspx");
  
  
  
          }
  
          catch (Exception ex)
  </code></pre>
  
  <p>I just don't know how to insert the right image just from the code? Thanks!</p>