Wednesday, August 18, 2010

ASP.Net file too large or exceeded buffer (ASP0251)

I've run into this problem a few times.  The problem is ASP's default is to limit the file buffer to 4MB.  If you get a file (or response) larger than that, it will choke.

In IIS6/7, you can run this command:
  • Click Start, click Run, type cmd, and then click OK.
  • cd /d %systemdrive%\inetpub\adminscripts
  • cscript.exe adsutil.vbs SET w3svc/aspbufferinglimit 20000000

I just found the setting in IIS7.5 in IIS Manager:

Sites -> Default Web Site -> Choose your site
Double Click on the "ASP" feature
Expand "Limits Properties"
Change the "Response Buffering Limit"

It defaults to : 4194304 (4MB)
I changed it to 10000000 (10MB) and clicked Apply, but still got the error
Then, I changed it to 20000000 (20MB), and the error went away

Wednesday, August 4, 2010

Database Restore Script

This is a quick database restore script.  It sets the database to SINGLE_USER so you don't get any "database in use" errors, then restores the database, then sets it back to MULTI_USER.

You need to run all the commands together.  It didn't work for me when I tried to run them separately.



   1:  ALTER DATABASE MyAppDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE
   2:    RESTORE DATABASE MyAppDB FROM DISK = 'E:\DBBackups\MyApp_db_201008032143.BAK' WITH REPLACE
   3:    ALTER DATABASE MyAppDB SET MULTI_USER

Wednesday, July 14, 2010

SQL DateTime Queries

Here are some basic DateTime queries to get the date you need.



declare @BeginDate datetime;
set @BeginDate = getdate(); 
 
select dateadd(dd, datediff(dd, 0, @BeginDate), 0)     -- Beginning of this day
select dateadd(dd, datediff(dd, 0, @BeginDate) + 1, 0) -- Beginning of next day
select dateadd(dd, datediff(dd, 0, @BeginDate) - 1, 0) -- Beginning of previous day
select dateadd(wk, datediff(wk, 0, @BeginDate), 0)     -- Beginning of this week (Monday)
select dateadd(wk, datediff(wk, 0, @BeginDate) + 1, 0) -- Beginning of next week (Monday)
select dateadd(wk, datediff(wk, 0, @BeginDate) - 1, 0) -- Beginning of previous week (Monday)
select dateadd(mm, datediff(mm, 0, @BeginDate), 0)     -- Beginning of this month
select dateadd(mm, datediff(mm, 0, @BeginDate) + 1, 0) -- Beginning of next month
select dateadd(mm, datediff(mm, 0, @BeginDate) - 1, 0) -- Beginning of previous month
select dateadd(qq, datediff(qq, 0, @BeginDate), 0)     -- Beginning of this quarter (Calendar)
select dateadd(qq, datediff(qq, 0, @BeginDate) + 1, 0) -- Beginning of next quarter (Calendar)
select dateadd(qq, datediff(qq, 0, @BeginDate) - 1, 0) -- Beginning of previous quarter (Calendar)
select dateadd(yy, datediff(yy, 0, @BeginDate), 0)     -- Beginning of this year
select dateadd(yy, datediff(yy, 0, @BeginDate) + 1, 0) -- Beginning of next year
select dateadd(yy, datediff(yy, 0, @BeginDate) - 1, 0) -- Beginning of previous year