title: exception "Input string was not in a correct format"
body: <p>I am trying to associate adminID(which is foriegn key) with my table Media. I retrieve the adminID, but when I convert it to int it throw exception "Input string was not in a correct format".</p>
  
  <pre><code>void Insert(string name, int size, string path)
  {
      SqlConnection connec = new SqlConnection(ConfigurationManager.ConnectionStrings["BloodDonorRegistrationConnectionString"].ConnectionString);
      string VidInsertQuary = "insert into Media(AdminID,Date,Time,Content,FileName,FilePath,TopicTittle,TopicDescr) values (@ad,@dt,@tm,@cc,@Fname,@Fpath,@TpTittle,@TpDes)";
      string AdminID = "select AdminID from Admin where Email='" + Session["UserID"]+"'";
  
  
  
      try
      {
          int tempid = 0;
          SqlCommand com2 = new SqlCommand(AdminID, connec);
          tempid = Convert.ToInt32(com2.ToString());
          SqlCommand com = new SqlCommand(VidInsertQuary, connec);
          connec.Open();
          com2.Parameters.AddWithValue("@ad",tempid);
          com.Parameters.AddWithValue("@dt", DateTime.Now.Date);
          com.Parameters.AddWithValue("@tm", DateTime.Now.TimeOfDay);
          com.Parameters.AddWithValue("@cc", size);
          com.Parameters.AddWithValue("@Fname", name);
          com.Parameters.AddWithValue("@Fpath", path);
          com.Parameters.AddWithValue("@TpTittle",TextBoxTittle.Text);
          com.Parameters.AddWithValue("@TpDes",TextBoxDescription.Text);
  
          com.ExecuteNonQuery();
          Response.Redirect("AdminVideoUpload.aspx");
  
      }
      catch (Exception ex)
      {
          string exp = "Problem occured";
          Response.Write(exp + ex.ToString());
      }
      finally
      {
          connec.Close();
      }
  }
  </code></pre>