Recently I had a task to save file on client machine. We usually save file on server and in ASP.NET the more familiar task to save on client side was to export gridview results to excel file. This time the task was to save an image on client machine. Following is the code that I followed. <pre name="code" class="html"> byte[] fileBytes = File.ReadAllBytes("D:\\Projects\\TestClientDownload\\images\\banner_ad_1.jpg"); Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "text/plain"; Response.AppendHeader("content-disposition", "attachment; filename=" + "banner_ad_1.jpg"); Response.AppendHeader("content-length", fileBytes.Length.ToString()); ...
While working in projects, I always used to wonder about maintaining Stored Procedures in Sql Server. The way in which we organize them is that we go on adding the required stored procedures with some name convention so that we can identify what is the module to which this SP refers. But as the project goes ahead modifications come, we go on adding required Stored Procedures and some Stored Procedures become obsolete because of business rule changes. But as far as I have observed in IT projects, these stored procedures are kept as it is and when the project completes no one has any idea about which Stored Procedures are currently in use and which are obsolete. But I have come across this post , which shows how to get probably unused SPs from Sql Server 2008. The query is as follows, which returns SPs which are not in procedure cache. //The first part gives list of all SPs and also works in SQL2005 Select p.name From sys.procedures as p wh...
Recently I came across an issue in Sql Server 2005, while running CROSS APPLY. The error says that Incorrect syntax near '.'. I tried to figure out all syntax that I could apply but it did not resolve the issue. Actually we need to set sp_dbcmptlevel level to 90. There are good blog posts for this here and here , which can save your valuable time.