| Author |
Recordset Get Fields
|
Danie Van Eeden
Greenhorn
Joined: Sep 03, 2003
Posts: 13
|
|
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
|
Regards<br />-dve83-
|
 |
Arulkumar Gopalan
Ranch Hand
Joined: Oct 13, 2003
Posts: 104
|
|
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(); for(int i=0;i<intNumberOfColumns;i++) { String strCoulmnName = rsmdObj.getcolumnName(i); } Is that what are you looking for?
|
Anbudan & Mahalo,<br />Arul<br /> <br />-Not a sun certified Java professional :-)
|
 |
Jason Menard
Sheriff
Joined: Nov 09, 2000
Posts: 6450
|
|
|
I'm going to move this to the JDBC forum.
|
Jason's Blog
|
 |
Danie Van Eeden
Greenhorn
Joined: Sep 03, 2003
Posts: 13
|
|
hi and thanks, ill try that out and let know if im still struggling. regards
|
 |
Danie Van Eeden
Greenhorn
Joined: Sep 03, 2003
Posts: 13
|
|
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
|
 |
 |
|
|
subject: Recordset Get Fields
|
|
|