public bool SaveImage(long subjectID, byte[] image, XmlDocument PropertyListXML)
{
ActivityLog(PropertyListXML, subjectID);
SessionManagement sm = new SessionManagement();
string connstr = ConfigurationManager.ConnectionStrings["ProfilesDB"].ConnectionString;
image = this.ResizeImageFile(image, 150);
SqlConnection dbconnection = new SqlConnection(connstr);
SqlCommand comm = new SqlCommand();
try
{
dbconnection.Open();
comm.Connection = dbconnection;
comm.CommandType = CommandType.Text;
//Save this chestnut for when we edit
using (SqlCommand cmd = new SqlCommand("exec [Profile.Data].[Person.AddPhoto] @Personid,@Photo", dbconnection))
{
// Replace 8000, below, with the correct size of the field
cmd.Parameters.Add("@Personid", SqlDbType.Int).Value = GetPersonID(subjectID);
cmd.Parameters.Add("@Photo", SqlDbType.VarBinary).Value = image;
cmd.ExecuteNonQuery();
cmd.Connection.Close();
}
comm.Connection.Close();
if (dbconnection.State != ConnectionState.Closed)
dbconnection.Close();
}
catch (Exception ex)
{
throw ex;
}
return true;
}