Hi,
I have a question on instantiating a new DataTable with a ResultSet that has column aliases. When we attempt to do this, the column alias name appears to be dropped in favor of the original query column name in the DataTable, although admittedly it is difficult to tell when debugging obfuscated code. Here's a code sample...
String query = "SELECT last_nm \"Last Name\" from hazel.pers_names where last_nm = \"SMITH\"";
PreparedStatement pStmt = conn.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rs = pStmt.executeQuery();
DataTable dt = new DataTable(resultSet);
PreparedStatement pStmt = conn.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rs = pStmt.executeQuery();
DataTable dt = new DataTable(resultSet);
When I dig into the ResultSet, I can see the properties columnName=Last Name, originalColumnName=LAST_NM in the debugger. However, the only DataColumn element in the DataTable under the DataColumnCollection is an entry of "LAST_NM", not "Last Name". In practice, we've found that when using DataTables, only the non-aliased columns in our SQL will be in the document after the mail merge. Is there a special approach for handling column aliases and DataTables we should be using? I've tried various forms of aliasing (no ticks, single ticks, double ticks) and haven't found a solution.
Thanks, John