These tips are pretty basic and can be found anywhere on the net, but they still can help your code.
- Buy a magic 8-ball (I use this for debugging)
- Store COM values once
When using values returned through COM you can store them locally to make your code more efficient. For example, instead of this:
If Session("data") = "something" Then
If Session("data") = "nothing" Then
data = Session("data")
If data = "something" Then
If data = "nothing" Then
This way you not making a call for the same data over and over.
- Put SQL in a variable
Instead of just executing the SQL statement directly like so:
Set SQL = oConn.Execute("SELECT * FROM MasterAccounts WHERE Login='ian'")
Use this instead:
SQL = "SELECT * FROM MasterAccounts WHERE " &
SQL = "Login='ian'"
Set oConnSelect = oConn.Execute(SQL)
This way you can write the info to the screen when you debug using the response object like this:
- Use Option Explicit in VBscript<% option explicit %>
When putting code into production try to use the 'Option Explicit' option in VBscript. This makes you declare each variable before they can be used. Undefined variables are a performance leech. You can use the following to turn this on:
- Place common functions in include file
If you have a common function that you want to use over and over, such as one to validate an email address, place it in include file (preferably in a common directory) and then you can access it from any page you want.
- Use Option Explicit in VBscript
If you have any comments or questions feel free to e-mail me.
IT Solutions Builder TOP IT RESOURCES TO MOVE YOUR BUSINESS FORWARD
Which topic are you interested in?
What is your company size?
What is your job title?
What is your job function?
Searching our resource database to find your matches...