another array problem

Discussion in 'C' started by meyup, May 29, 2010.

  1. meyup

    meyup New Member

    Joined:
    Feb 15, 2010
    Messages:
    102
    Likes Received:
    0
    Trophy Points:
    0
    I create with:
    Code:
    CArray <Suchparameter*, Suchparameter*> SPA;
    CArray as a member variable, which is creating problems from without.
    But when I later pointed so

    Code:
    SPA [1] -> getUrl (1);
    want accessed, the program crashes with exception of the untreated ab.Wenn search parameters I do not grab the array operates in the function.
     
  2. pankaj.sea

    pankaj.sea New Member

    Joined:
    Apr 6, 2009
    Messages:
    461
    Likes Received:
    13
    Trophy Points:
    0
    Occupation:
    Web Developer
    Location:
    Kolkata
    Home Page:
    http://ipankaj.net
    Hi,

    Try going in with the debugger and see exactly where he abschmiert. I suspect that you have not used one occupied index or no useful pointers have registered.
     
  3. meyup

    meyup New Member

    Joined:
    Feb 15, 2010
    Messages:
    102
    Likes Received:
    0
    Trophy Points:
    0
    He smears from when a member variable of the query parameters to access will.Ich habs also in creating the classes because debuged, is easily resorted to it.
    So I fill the array:
    Code:
    SPA.Add ( new search parameters (val.intVal));
     
  4. pankaj.sea

    pankaj.sea New Member

    Joined:
    Apr 6, 2009
    Messages:
    461
    Likes Received:
    13
    Trophy Points:
    0
    Occupation:
    Web Developer
    Location:
    Kolkata
    Home Page:
    http://ipankaj.net
    Another approach to error Search:

    Substitute times
    Code:
    SPA [1] -> getUrl (1);
    by
    Code:
    * = Search parameters pSuchTemp SPA [1]; 
    pSuchTemp-> getUrl (1);
    and look in the debugger's address pSuchTemp and content more closely. If you something strange happens, then you have at least one track.
    Otherwise, I would need a little more code (but can not tell you how I look at what an accidental).
     
  5. meyup

    meyup New Member

    Joined:
    Feb 15, 2010
    Messages:
    102
    Likes Received:
    0
    Trophy Points:
    0
    The program is supposed to, from a database into the array shoveling data, but for some reason is SPA [0] correctly filled not have the program so it changed the array until an item goes through this, I would now runs es.Trotzdem like to know why the program macht.Hier the array is the entire code of the fills.

    Code:
    CDaoData base archive; 
    COleVariant val; 
    archiv.Open (" c: \ \ my documents \ \ db3.mdb "); 
    CDaoRecordset r (& archive); 
    r.Open dbOpenDynaset (, " Select ID from query parameters , "dbReadOnly), 
      if ( ! r.IsEOF ()) 
    ( 
    SPA.SetSize (r.GetRecordCount ()); 
    r.MoveFirst (); 
       while (! r.IsEOF ()) 
    ( 
    r.GetFieldValue (" ID ", val); 
    SPA.Add ( new search parameters (val.intVal)); 
    r.MoveNext (); 
    ) 
    ) 
    r.Close (); 
    archiv.Close ();
    
     
  6. pankaj.sea

    pankaj.sea New Member

    Joined:
    Apr 6, 2009
    Messages:
    461
    Likes Received:
    13
    Trophy Points:
    0
    Occupation:
    Web Developer
    Location:
    Kolkata
    Home Page:
    http://ipankaj.net
    I can not guarantee that my explanation is correct, but for me there is the as follows:
    Code:
    SPA.SetSize (r.GetRecordCount ());
    Since you r still no MoveLast () or similar to you, you will not show the real number of lines, special ia a first The lay so an array of size 1 to (your element 0, then that does not work).
    Below you will:
    Code:
    SPA.Add ( new search parameters (val.intVal));
    This statement you Haeger exsitierende to the array to a new entry and fill it with "new search parameters ..." .
    In sum, explains the behavior of your program.

    Remedy:
    Either:
    Make the SetSize r.MoveLast before () and replace this
    Code:
    SPA.Add ( new search parameters (val.intVal))
    by
    Code:
    SPA [iIndex] = new Parameters (val.intVal)
    ,
    your being you have to make up from 0 duchlaufen loop in iIndex.
    Or
    you your savings SetSize (). Then your first causes "Add" the produce of the 0-th element, etc.
     
  7. meyup

    meyup New Member

    Joined:
    Feb 15, 2010
    Messages:
    102
    Likes Received:
    0
    Trophy Points:
    0
    Thanks now running.
    :D :) :D
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice