April 30, 2002

Avoid Copying Data

You can use the name of a Function or Property Get procedure as a local variable anywhere in the procedure. If your procedure returns a String or UDT type, writing directly to the function name instead of a temporary variable saves you from making a full copy of your data

Determine a Control

To determine whether a control is a member of a control array, you can reference its Index property and handle the generated error when the control is not in an array. Alternatively, you can use the TypeName function, which returns “Object” for members of a control array. The trick to

Ascertain OK or Cancel From the InputBox

When the user presses Cancel on a VB InputBox, the string returned is a vbNullString. If the user inputs a zero-length string and presses OK, the return string is empty (“”). Unfortunately, in VB, you can

Force Tri-State Checkbox Cycling

The CheckBox control in VB supports three positions: Checked, Unchecked, and Grayed. Unfortunately, the default behavior for the control is to cycle between Checked and Unchecked. To set it to Grayed, you must do it programatically. This code shows you how to cycle between the three positions (the order is

Avoid Premature Object Creation

This is a simple tip that proves useful in the long run. Consider the following example: void someFunction() {Date d= new Date(); // The Date object is created outside the scope where it is used.If (…) { // The Date object is actually used here.}} Define the objects in the

Handling Single Quotes in a SQL Query

To insert data with single quotes, place 2 single quotes instead of 1 single quote, like this: create table MyTable ( Field1 varchar(10))goinsert MyTable (Field1) select ‘A1111”1111’ UNION ALL select ‘F”66666666’ In the same way, you can retrieve data by using 2 single quotes. For example: select * from Mytable

Insert Multi-Lingual Characters in JDBC

This method allows you to insert multi-lingual characters into an Oracle database. In this tip, the column type is varchar2. The multi-lingual string is converted to its unicode value and a special character is inserted between the characters. The following code demonstrates: import java.sql.*;import java.util.*;public class MultiLang{ String value=””; Connection

Make a ResultSet Scrollable

This code can also be used to navigate through the Resultset backward or forward, or to perform insertions, deletions and updates to update the database. //load JDBC Driver// Get the ConnectionStatementstmt=connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);ResultSet resultset=stmt.executeQuery(“SQL ..” );resultset.absolute(3);//Moves the cursor to the given row number.resultset.previous();//Moves the cursor to the previous row.

No more posts to show