i’m doing a project where i need to retrieve data from one field of access and display it on JTextField and its serial no.select fieldname from tablename
but it’l select all rows.also how to retrieve data(whole row) with random serial number
i’m doing a project where i need to retrieve data from one field of
Share
For the query to select the field data,
Here,
columnNameshould be something like the primary key andcolumnValuewill be a unique value (like a serial number). Then it will return the field data associated with the row with the specificcolumnValue.For setting it into the
JTextField,Here,
resultSetshould return only one value (with the query specified above).As for your other question, if your serials are irregular, get all the serials from the table:
And then add them to a
Collection(like aVector). Then write an algorithm to generate a random index and retrieve the data from the Collection with that index (vector.elementAt([yourIndex])).Then again query the table in the database for the row associated with that serial:
…and you’ll get the relevant row.