Amir Mirkamali

امیر میرکمالی

Which Content-Type you must set for binary stream, to download when using Response.Binarywrite

Response.ContentType = "application/force-download";

Response.AddHeader("Content-Disposition", "attachment;filename=\"" + Filename + "\"");

Response.BinaryWrite(yourbuffer);

Response.End();

Shrink Database log file in SQL Server

if you want to shrink database log file just run this codes with your database name:

BACKUP LOG yourdbname WITH TRUNCATE_ONLY
DBCC SHRINKFILE(yourdbname_log, 2)

this code will shrink and reduce your database log file to 2MB

 

in sql server 2008 above code not work and you must use this code


USE yourdbname;
 GO

 ALTER DATABASE yourdbname
 SET RECOVERY SIMPLE;
 GO
 
 DBCC SHRINKFILE (yourdbname_log, 10);
 GO
 
 ALTER DATABASE yourdbname
 SET RECOVERY FULL;
 GO