Saturday, April 20, 2013

Folders Becoming Shortcut Ink Virus

But then if you encounter this situation, do not panic! Your files are still there, not deleted. You can just use a simple way to get all your files back:

1. Click start > Run
2. Type: attrib -h -r -s /s /d g:\*.*
(But change g: to the drive letter of your device)
3. press enter
4. Wait for a while, around 2 minutes... and open the drive.
Bingo!

Monday, April 1, 2013

ASP + Ms Access: Add Now() to datetime data type

sql = sql & "values('" & username & "','" & pwd & "','" & firstname & "','" & lastname & "','" & email & "', " & role & ",'" & status_ & "',Now())"

ASP + Ms Access: Adding data into Ms Access, data type: number

sql = sql & "values('" & username & "','" & pwd & "','" & firstname & "','" & lastname & "','" & email & "', " & role & ")"

ASP + Ms Access: Permissions on Content Folders

Problem
When you are deploying a classic ASP application that uses an Access database you may see this error because the lock file for the Access database cannot be created. To further explain this scenario: Access databases are kept in files that use an .MDB file name extension. When you try to add to the database or update the data, the Microsoft JET database engine attempts to create a lock file with that uses an .LDB file name extension. If the Access database is stored within the content area of your Web site, by default the JET database engine will not have sufficient access permissions to update the database and you will see the following error message displayed in a Web browser:

Microsoft JET Database Engine error '80004005'

Operation must use an updateable query.

/example.asp, line 100


Solution
This error clearly lists the lock file as the cause of the failure. To resolve the issue, you can grant the application pool's impersonated identity read/write permission to the folder where the Access database is located, but that poses a security risk for your Web site. A better solution would be to move the Access database out of your Web site's content area to a folder where the application pool's impersonated identity has read/write permission, then create a System Data Source Name (DSN) that points to the database location. Your ASP code would then reference the System DSN in the connection string instead of the physical path of the database, which is also better for security. If you must store the database in the content area, you should always store the database in a folder that is blocked by default by the IIS request-filtering features, such as the App_Data folder.

Right-click on Ms Access > Properties > Security > IIS_IUSRS (Full Control) and Users (Full Control)



ASP + Ms Access: An error occurred on the server when processing the URL. Please contact the system administrator. If you are the system administrator please click here to find out more about this error.

Problem
An error occurred on the server when processing the URL. Please contact the system administrator.  If you are the system administrator please click here to find out more about this error.

Solution:
Classic ASP: Security is Painful

I had to write some good old classic ASP code today and my classic ASP coding skills are so rusty that I put tons of errors in the code. I'm used to having basic ASP error messages on IIS5 and 6 which usually help me to track down problems. On IIS7 I only got the following though:
An error occurred on the server when processing the URL. Please contact the system administrator
After investigating a bit I figured out that we changed the default for the "scriptErrorSentToBrowser" flag in IIS7. It's now false and you always get the error above. Here is how to change it:
1) Start an elevated command prompt. Right-click the command shell item in the Start-Accessories menu and select "Run as Administrator".
2) Run the following command: %windir%\system32\inetsrv\appcmd set config -section:asp -scriptErrorSentToBrowser:true
Once you are done with debugging your ASP app please set it back to false. There are lots of 'evildoers' out there! :)