Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Query database

 
Candy Bortniker
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to get some information from a table and use it to populate a vector. I have examples of how to query the table but I don't have any examples on what to do with the info once I get it. Like once I get a stockname from the table how do I refer to that in the program. Am I making myself clear?
 
Dirk Schreckmann
Sheriff
Posts: 7023
 
Candy Bortniker
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a statement in my program like:

What this returns is the values in the first field of my table. So I would think that rs.getString(2) would return the values in the second field of my table. But no it throws an exception instead. So how do I go about getting the second field?
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could do it in the following manner.
Consider a table named student with three columns - idNo, fName, and lName - that are all varchars. The following code would print to the console a listing of everybody in the table.Does that help to give you an idea?
 
Candy Bortniker
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is definitely helpful. I can understand doing it that way much better than the way I was doing it. Thanks.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic