November 25, 2003

Find and Replace a String in a Table

The folowing stored procedure will find and replace a string in a table: CREATE PROCEDURE [dbo].[sp_st_FindANDReplaceString]@Tablename varchar(20),@FieldName varchar(20),@FindString varchar(30),@RepalceString varchar(30)ASdeclare @sqlstring varchar(8000)Select @sqlstring = “Update ” + @Tablename + ” Set ” + @FieldName + “= Replace(” + @FieldName + “,'” + @FindString + “‘,'” + @RepalceString +”‘)”execute (@sqlstring)GOEXEC sp_st_FindANDReplaceString

A Fabricated ADO Recordset

A disconnected recordset is a recordset which does not hold an active connection. A fabricated recordset can be viewed as a variation of a disconnected recordset. The variation in the fabricated recordset is that the connection is never established. You can use this type of ADO recordset object as a

Get the Current Host Info

This program prints out the name and the address (in both textual and numerical forms) of the machine on which its run, using the InetAddress singleton. import java.net.*;public class CurrentHost { public static void main(String[] args) throws UnknownHostException { InetAddress address = InetAddress.getLocalHost(); System.out.println(“This host’s name: ” + address.getHostName()); System.out.println(“This

Replace All Occurrences of One String with Another String

All programmers?especially database programmers?require a function that replaces all occurrences of one substring with another string. For example, they need to replace the single quotes in strings passed to an Oracle database with two single quotes. Using recursion in this algorithm limits its usefulness slightly below that of VB6s native

Serialize Data Using a PropertyBag

You can serialize your data quickly by placing it into a PropertyBag object, then reading the PropertyBags Contents property. This property is really a Byte array that is a serial representation of the data in your PropertyBag object. You can use this byte array for many purposes, including an efficient

Manage Errors with Sparse Line Numbering

You might have used line numbering to track error locations, but this technique can be a pain (and ugly) to use for every line. Sparse line numbers help you locate code sections generating errors through the intrinsic Erl (error line) property. Erl captures the most recent line number so you