This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi, im using a microsoft Connection package to connect to MS SQL Server and im using MS J++ compiler. After I declare a recordset and populate it with info from a database table, I would like to be able to get the field names from that recordset. why? because im selecting all records from the database table and I dont know the field names. Ive seen the getField() method, but it only seems to get the value from that specific field, and I have no idea what the getFields() method (note the "s") does. Im writing a small search engine thingy for a personal project, and any help would be appreciated. regards dve83
If you want to get the column names you can use the interface ResultSetMetaData which has the required methods.getColumnName(int column), getColumnType(int column) . Sample code: ResultSet rsObj = stmt.executeQuery("SELECT a, b, c FROM TABLE2"); ResultSetMetaData rsmdObj = rsObj.getMetaData(); int intNumberOfColumns = rsmdObj.getColumnCount();
hi and thanks, ill try that out and let know if im still struggling. regards
Danie Van Eeden
Joined: Sep 03, 2003
hi , im back again. what do i have to imoprt to get ResultSetMetaData as available class/type. Im currently using com.ms.fwc.data.* (i think that correctly spelled!?) and does this resultsetmetadata idea support getting table names from the database as well. Ill most probably start messing about with and figure it out myself, but i just thought id ask. thanks in advance