title: Converting stored images in DB to string and back to byte?
body: <p>So I have a couple tabs in a tabcontrol which do the task of registering and modifying info about a client. The first one among other info, saves a picture using OpenFileDialog and then store it into 'lblImagePath.Text' to use bitmap with it so I can save it into de DB, which can be seen in this code:</p>
  <pre><code>public partial class form : Form
  
  {
          String strDBFilePath = &quot;&quot;;
          String strFilePath = &quot;&quot;;
          Image DefaultImage;
          byte[] ImageByteArray;
          byte[] ImageByteArrayMod;
  
  private void btnAddUser_Click(object sender, EventArgs e)
          {
              if (txtEmailPersonal.Text != &quot;&quot;)
              {
                  try
                  {
                      Image temp = new Bitmap(strFilePath);
                      MemoryStream ms = new MemoryStream();
                      temp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                      ImageByteArray = ms.ToArray();
                      SqlConnection con = new SqlConnection();
                      con.ConnectionString = CONEXION.CONEXIONMAESTRA.conexion;
                      con.Open();
                      SqlCommand cmd = new SqlCommand();
                      cmd = new SqlCommand(&quot;insert_user&quot;, con);
                      cmd.CommandType = CommandType.StoredProcedure;
                      cmd.Parameters.AddWithValue(&quot;@email&quot;, txtEmailPersonal.Text);
                      cmd.Parameters.AddWithValue(&quot;@password&quot;, txtPasswordPersonal.Text);
                      cmd.Parameters.AddWithValue(&quot;@profile_picture&quot;, ImageByteArray);
                      cmd.Parameters.AddWithValue(&quot;@imageFile_name&quot;, lblImagePath.Text);
                      cmd.ExecuteNonQuery();
                      con.Close();
                  }
                  catch (Exception ex)
                  {
                      MessageBox.Show(ex.Message);
                  }
               mostrar();
              }
          }
  </code></pre>
  <p>}</p>
  <p>Everything goes smooth, register form works and I'm using a datagridview to visualize it. When I double click a row from the dgv, all the info loads into the second tab and let's me modify all the info except the profile picture, which can be previewed in a picturebox but doesnt load any other information about it, so when I hit the 'save changes' button, it won't let me proceed with it until I re-upload a profile picture, since path is non existant  prior to that action. This is the code for user modifying:</p>
  <pre><code>private void btnGuardarCambiosPersonal_Click(object sender, EventArgs e)
          {
              if (txtEmailPersonalMod.Text != &quot;&quot;)
              {
                  try
                  {
                      Image temp = new Bitmap(strDBFilePath);
                      MemoryStream ms = new MemoryStream();
                      temp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                      ImageByteArrayMod = ms.ToArray();
                      SqlConnection con = new SqlConnection();
                      con.ConnectionString = CONEXION.CONEXIONMAESTRA.conexion;
                      con.Open();
                      SqlCommand cmd = new SqlCommand();
                      cmd = new SqlCommand(&quot;modify_user&quot;, con);
                      cmd.CommandType = CommandType.StoredProcedure;
                      cmd.Parameters.AddWithValue(&quot;@correo&quot;, txtEmailPersonalMod.Text);
                      cmd.Parameters.AddWithValue(&quot;@password&quot;, txtPasswordPersonalMod.Text);
                      cmd.Parameters.AddWithValue(&quot;@profile_picture&quot;, ImageByteArrayMod);
                      cmd.Parameters.AddWithValue(&quot;@imageFile_name&quot;, lblFilePathMod.Text);
                      cmd.ExecuteNonQuery();
                      con.Close();
                  }
                  catch (Exception ex)
                  {
                      MessageBox.Show(ex.Message);
                  }
                  mostrar();
              }
  
          }
  </code></pre>
  <p>Some of the stuff I have in there might actually be useless to accomplish what I want. So I'll try to be as clear as possible, I want to be able to keep the current profile picture if another profile picture isn't uploaded to replace it.</p>
  <p>As you might also see, instead of doing the query directly on the code, I'm using stored procedures, the idea is to keep those stored procedures and try to do the adjusting in the code.</p>