I am using Net framework 4.0 and Sql Server 2012 for the development. There is an error occurring randomly while performing database operation in the web application in asp.net. I have call some sql queries from code behind file. It is occurring for large document with size greater than 300KB. How to increase size.
EDIT :
It is mainly occurring while view image files and saving binary data in the database
Below is the code where I got error
int isUpdateIDProof = 1;
SqlParameter paramInsertIDProof = null;
SqlCommand cmdInsertIDProof = new SqlCommand("OnBoarding_InsertUploadedIDProof", con);
cmdInsertIDProof.CommandType = CommandType.StoredProcedure;
paramInsertIDProof = new SqlParameter("@FileCaption", SqlDbType.VarChar, 100);
paramInsertIDProof.Direction = ParameterDirection.Input;
paramInsertIDProof.Value = txtIDProofDescription.Text;
cmdInsertIDProof.Parameters.Add(paramInsertIDProof);
paramInsertIDProof = new SqlParameter("@FileData", SqlDbType.VarBinary,1000000000);
paramInsertIDProof.Direction = ParameterDirection.Input;
paramInsertIDProof.Value = OnBoardingFileData;
cmdInsertIDProof.Parameters.Add(paramInsertIDProof);
paramInsertIDProof = new SqlParameter("@FileNames", SqlDbType.VarChar, 100);
paramInsertIDProof.Direction = ParameterDirection.Input;
paramInsertIDProof.Value = fileName;
cmdInsertIDProof.Parameters.Add(paramInsertIDProof);
//execute SQL COMMAND
con.Open();
cmdInsertIDProof.ExecuteNonQuery();
con.Close();
There is not any issue with your code
. Its all about the memory leakage at your database server by the way you are storing the image. If you are using any sql server project dll for compressing and decompressing the binary data, please check this.
To hide your error, you can restart sql server service. It will automatically refresh the memory and will start working fine. I had the same problem some year back.