CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2001
    Posts
    140

    Vector of Vectors: Accessing a value

    I would like to use a value stored in a vector of vectors as a Prepared Statement parameter.
    This attempt:
    Code:
    for ( int i = 1; i < ( 10 ); i++ ) {			
    ...
    	pstmt.setString( 4, (String)((Vector)orderDataVector.elementAt(i)).elementAt(2) );	
    ...
    
    }
    Returns this error:
    ...: Method elementAt(int) not found in class java.lang.Object.
    insertSpecs.setString( 4, (String)((Vector)orderDataVector.elementAt(i)).elementAt(2) ); // supplied_materials;
    ^
    How do I fix this?

    Many thanks in advance.

  2. #2
    Join Date
    Apr 2001
    Posts
    140
    My BIG Mistake:

    I created this problem by adding a 2-dimensional array:
    String[][] orderDataVector = {.

    Changing its name to String[][] orderDataArray seems to have solved the problem, allowing the use of the original code.

    Many thanks for your attention to the post.

  3. #3
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163
    The problem in your first post was due to not casting the Object element returned from the main Vector to a Vector - i.e. you were casting the main Vector (probably not necessary), but not casting the Vector objects it contained.

    I can't make sense of your second post...

    Roosters they can roost also, which don't seem fair when crows can't crow,
    so maybe roosters stand more show. Still, I dunno...
    Please use &#91;CODE]...your code here...&#91;/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured