You can improve both your productivity and your Web applications’ performance by judiciously using server Includes. And if you use Visual Basic (VB) instead of Active Server Pages (ASP) for database development, you can use Includes in your code modules to reap the same benefits.
How’s that, you say? For example, you can collect SQL Server Magazine’s tips and techniques for creating high-performance code and build those code routines into your Include files. You and other developers can then use those routines to help build your applications.
Consider the following function, called RunSQL:
Function RunSQL(strSQL) Dim cmd Set cmd = CreateObject("ADODB.Command") cmd.ActiveConnection = GetDSN() cmd.CommandText = strSQL cmd.CommandType = adCmdText cmd.Execute , , ADODB.adExecuteNoRecords Set cmd.ActiveConnection = Nothing Set cmd = Nothing End Function
The RunSQL function executes an SQL statement but doesn’t generate a record set. This function is particularly handy for Insert, Update, and Delete statements that don’t return a record set. You could just rely on your developers to remember how to execute SQL statements and not return a record set. Or you could put this function in an Include file so your developers could simply call RunSQL and pass in the SQL statement. In addition, most programmers will likely use RunSQL over and over instead of writing the ADO code themselves, so they’ll have more time to perform other tasks.
You can even automate the use of Includes in your development tools. If you’re using Visual InterDev, for instance, you can place the Include statement on the Toolbox:
Then, whenever you need the Include statement, you can drag it from the Toolbox and drop it on the page. You can also place the functions in the Include file on the Toolbox. Even better, you can build code libraries into COM objects, then put references to methods on the Toolbox. You have all sorts of possibilities for using Includes to speed up application development and application performance.