January 1, 2003

Add a slash to directory names

If you have defined a default document for a given IIS virtual directory, any link pointing to the directory will actually point to the default document for that directory. However, you should keep in mind that loading a page in this way requires two round-trips from the client to the

Most runtime errors don’t rollback transaction

Many developers mistakenly believe that any error inside a transaction will make the transaction fail and automatically rollback. However, this is true only for fatal errors, such as most errors with severity equal to 16 or higher. The commonest runtime error – for example duplicate primary keys, violation of unique

Retreive information about SQL Server

You may retrieve a few important information about a connection to SQL Server by querying the server through appropriate @@ global variables. For example, the following routine takes an ADO Connection object that points to SQL Server and prints a few information about the connection: Dim cn As New ADODB.ConnectionDim

The WITH CHECK OPTION option with views

SQL Server’s views are updateable, but it is possible that when you insert a new record or update an existing record, the record added or modified doesn’t logical belog to the view any longer. For example, consider the following view:CREATE VIEW authors_CA AS ( SELECT * FROM Authors WHERE state=’CA’

GetHtmlPageSource – Get the HTML of a page using MSXML library

‘ Getting the HTML code of any page on the web’ NOTE: requires the Microsoft XML library’ Example:’ Text1.Text = GetHtmlPageSource(“http://www.vb2themax.com/Default.asp”)Function GetHtmlPageSource(ByVal URL As String) Dim objHTTP As New XMLHTTP ‘ add the http:// in case it isn’t already present in the specified URL If Left$(URL, 7) “http://” Then URL

RLEUncompress – Uncompress data compressed using RLECompress

Private Declare Sub CopyMemory Lib “kernel32” Alias “RtlMoveMemory” (dest As _ Any, source As Any, ByVal Bytes As Long)’ Uncompress a block of data compressed with RLECompress” Returns TRUE if successful (this version either returns True or raises an ‘ error)” ADDRESS points to the buffer that holds the compressed

Swap the values of two columns

At times you may need to swap the values of two columns of the same SQL Server table. For example, suppose that you realized that the fname column of the Employee table contains the last name of each employee, and vice versa. Typically you do this from VB using a

Calculate the product of a field

The SQL language includes the SUM() aggregate function, that evaluates the sum of all the values in a given column, but it doesn’t include a PROD() function that evaluates the product of those values. While this function is surely less commonly useful than SUM(), there are cases when you’d like

No more posts to show