April 18, 2007

Everyday Use of Generics

he .NET 2.0 Framework now supports a new style of strongly typed collections called generics. This article demonstrates how to use generics in your .NET code. It would be nice to begin by explaining in simple terms what generics are…but it is hard to explain exactly what generics are. Generics

Improved Pinging in .NET 2.0

Using the Send method of the Ping class (in System.Net.NetworkInformation namespace) takes the hostname as a parameter. This captures the reply in the PingReply object, as shown below: //CodePing ping = new Ping();PingReply reply = ping.Send(“www.DevX.com”); To determine whether your ping was successful, use the Status property of the PingReply

Get the Keys for Rows Added by an INSERT Statement

This tip shows how to get the keys generated for the rows added by an INSERT statement. Statement st=null;PreparedStatement pst=null;Connection conn=null;ResultSet rs=null;ResultSetMetaData rsmd=null;…try { st= conn.createStatement(); }catch (SQLException e) {System.out.println(e.getMessage());}try { pst= new conn.prepareStatement(INSERT INTO table_name (field1, field2, …) VALUES](?, ?, …),Statement.RETURN_GENERATED_KEYS); pst.settype(1,val_1); pst.settype(2,val_2); … pst.settype(n,val_n); pst.executeUpdate(); rs =pst.getGeneratedKeys(); if

Convert Text into a Table in Microsoft Word

Microsoft Word has a function that lets you convert text into a table very quickly. Suppose you have a word list that you think would be better displayed in a table. All you need is a separator (like a comma, tab, paragraph, or any other character). Just follow these steps:

Use OLE Structured Storage to Get a List of Worksheet Names

ActiveX Data Objects (ADO) is a proven technology to access various data sources on computers that run Microsoft Windows. It provides an abstract interface to data stored in a wide range of file formats such as Microsoft Excel; it also specifies methods to obtain metadata, such as schema information, of

Workaround for the SQL DISTINCT Clause

The SQL DISTINCT clause isn’t case sensitive, which means that your query might end up pulling records with different cases. A simple fix for this is to use the COLLATE clause in conjunction with the DISTINCT clause. Use sql_latin1_general_cp1_ci_ai for case sensitive distinct clause: a) CASE INSENSITIVE DISTINCT CLAUSESELECT DISTINCT

An Overview of HTML 5

he Web Hypertext Application Technology Working Group (WHATWG) is formalizing a specification known as HTML5 or Web Applications 1.0 that should standardize some of the ambiguities and disconnects that have emerged with HTML and related web technologies. This article discusses some of the features and functionality of the proposed HTML5

Convert “Little-Endian” to “Big-Endian”

This tip outlines two simple methods that help you to convert a number from the “little-endian” format to the “big-endian” format. // 2-byte numberint SHORT_little_endian_TO_big_endian(int i){ return ((i>>8)&0xff)+((i