I had a strange problem in a project that I am currently working on:
I load the file into the table as varbinary as follows, but ExecuteNonQuery gets stuck for about a minute.
cmd.Parameters.Add("@FichierBinary_IN", SqlDbType.VarBinary, -1).Value = data;
cmd.ExecuteNonQuery();
Strange, when I make a manual selection in the database, I see that the row was successfully created in a few seconds, and the execution is still hanging.
select top 1 * from [Actions].[ItemFichier]
order by IdItemFichier DESC
The stored procedure that I call is pretty simple: just one insert in the table, without any logic. When I start manual insertion in SSMS with a copy of what I can get through the SQL profiler, it runs almost instantly.
What could be the source of this problem?
EDIT: DB Call Code Added
byte[] data = null;
MemoryStream target = new MemoryStream();
fichier.InputStream.CopyTo(target);
data = ImageHelper.ScaleImage(target.ToArray(), 1024, 1024);
var objParametre = new{
FichierNom = fileName,
MimeType = mimeType,
Extension = ext,
IdAction = idAction,
IdVariance = idVariance,
FichierParentItemType = paramFichierParentItemType,
IdParentTemp = idParentTemp
};
using (SqlCommand cmd = AppUTrakk.Current.SqlHelper.CreateCommand("Actions.pAddSetItemFichier", objParametre))
{
cmd.CommandTimeout = 180;
cmd.Parameters.Add("@FichierBinary_IN", SqlDbType.VarBinary, -1).Value = data;
cmd.ExecuteNonQuery();
}
AppUTrakk.Current.SqlHelper.CreateCommand just creates a SqlCommand / connection with some default options, and fichier is an HttpPostedFileBase.