Board index » cppbuilder » Invalid pointer operation

Invalid pointer operation

Hi,

I have used BCB4 Prof with SP2 wrote a program, and the main function of my
program is to read records from Table A (assume Table A is contains 112 rows
of records) and it would generate some other tables with records, depended
on the RecordCount of Table A - in this case, 112. For example:
Table001.dbf, Table002.dbf, ., Table111.dbf, Table112.dbf.

Then, my program would retrieve all the records from the particular table
(Table001 follow by Tables002, until Table112) to show on a QuickRep and
print it, one by one.
(Retrieve records from Table001, shown on QuickRep, and lastly print the
report. Then, retrieve Table002., until Table112).

Unfortunately, the program is only performed the tasks above correctly
before the Table102. In other words, it just generated the first 101 tables
and STOP.

The error messages below were occurred, once the program stops: -

Invalid pointer operation ->Press Enter

The exception unknown software exception [0x0eedfade] occurred in the
application at location 0x77f1d479. -> Press Enter

Address violation at address 004D157E in module 'ProgramName.exe'. Write of
address 004A19AC. - Press Enter

The instruction at "0x004d1cf0" referenced memory at 0x00d627fc". The memory
could not be "read".

I have tried to run my program on two different machines and both machine
also returned the similar error messages.

Machine 1:
OS: Windows NT 4.0 (SP6)
Processor: Intel P-III 550 MHz
RAM: 128 MB SDRAM

Machine 2:
OS: Windows 98 SE
Processor: Cyrix M-II 300 MHz
RAM: 128 MB SDRAM

What went wrong? Memory usage error? Please help!

Thanks in advance.

Regards,
ascll
as...@yahoo.com

 

Re:Invalid pointer operation


"ascll" <as...@yahoo.com> schrieb im Newsbeitrag news:3b4ebfd2_2@dnews...

Quote

> ........................
> Invalid pointer operation ->Press Enter

> The exception unknown software exception [0x0eedfade] occurred in the
> application at location 0x77f1d479. -> Press Enter

I guess it's something wrong somewhere with 'delete': e.g.  delete twice or
"delete" instead "delete[]" .

Christian.

Re:Invalid pointer operation


// NO PROBLEM OCCURRED, IF I DISABLE THE CODES BELOW
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=-=-=-

      // To generate Dealer's monthly statement table file. Example:
CUSTOMER_A_200106.dbf

      Tables_DM -> DealerJSRec -> Open();
      Tables_DM -> DealerJSRec -> First();

      // get the total number of dealers' records stored in DealerJSRec.dbf
      int iTotalDealer = Tables_DM -> DealerJSRec -> RecordCount;

      for( int i = 1; i <= iTotalDealer; i++ ) // for( 5 )
      {
         iPrintStatementFlag = 0;

         asDealerCode = Tables_DM -> DealerJSRec ->
ieldByName( "DealerCode" ) -> AsString;

         // AnsiString -> char
         strcpy( cFileName, asDealerCode.c_str() );
         Len = strlen( cFileName );

         strcpy ( cFileName + Len, "_" );
         Len = strlen( cFileName );

         strcpy( cFileName + Len, cYear );
         Len = strlen( cFileName );

         // Put a "0" in front, if the cMonth is single character
         iLen = strlen( cMonth );
         if( iLen == 1 )
         {
            strcpy( cFileName + Len, "0" );
            Len = strlen( cFileName );
         }

         strcpy( cFileName + Len, cMonth );
         Len = strlen( cFileName );

         strcpy( cFileName + Len, ".dbf" );

         Tables_DM -> TempSpecifiedDealer -> TableName = cFileName;

         BatchMove1 -> Source = Tables_DM -> DealerTemplate; // Just having
4 fields
         BatchMove1 -> Destination = Tables_DM -> TempSpecifiedDealer; //
Dummy table

file://---------------------------------------------------------------------
------

         // Copy records from Tables_DM -> Temp
         // ( would refer to specified Dealer table. Example:
CUSTOMER_A.dbf )
         // to Tables_DM -> TempSpecifiedDealer ( already pointed to
CUSTOMER_A_200106.dbf ),
         // if the DateFlag is MATCHED

         // Make the asDealerCode equal to "CUSTOMER_A.dbf"
         iLen = strlen( asDealerCode.c_str() );
         strcpy( asDealerCode.c_str() + iLen, ".dbf" );

         Tables_DM -> Temp -> TableName = asDealerCode;

         Tables_DM -> Temp -> Open();
         Tables_DM -> Temp -> First();

         // Used for BatchMove1 as flag, it only would be execute just for
the 1st time,
         // but NOT the following
         iDetectBatchMove = 0;

         while( !Tables_DM -> Temp -> Eof )
         {
            if( DateFlag == Tables_DM -> Temp -> FieldByName( "Date" ) ->
AsString.SubString( 4, 7 ) ) // if (0)
            {
               // Print the Dealer's statement, since the Dealer is having
record(s)
               iPrintStatementFlag = 1;

               ++iDetectBatchMove;

               // Duplicated a table from the DealerTemplate to "cFileName -
CUSTOMER_A_200106.dbf",
               // if CUSTOMER_A.dbf is having record(s)
               if( iDetectBatchMove <= 1 ) // Just run one time
               {
                  BatchMove1 -> Execute();
               }

               // Copy records from Temp( CUSTOMER_A.dbf ) to
TempSpecifiedDealer( CUSTOMER_A_200106.dbf )
               Tables_DM -> TempSpecifiedDealer -> Open();

               Tables_DM -> TempSpecifiedDealer -> Append();

               Tables_DM -> TempSpecifiedDealer -> FieldByName( "Date" ) ->
AsString =
               Tables_DM -> Temp -> FieldByName( "Date" ) -> AsString;

               Tables_DM -> TempSpecifiedDealer -> FieldByName( "Model" ) ->
AsString =
               Tables_DM -> Temp -> FieldByName( "Model" ) -> AsString;

               Tables_DM -> TempSpecifiedDealer ->
FieldByName( "InvoiceNo" ) -> AsInteger =
               Tables_DM -> Temp -> FieldByName( "InvoiceNo" ) -> AsInteger;

               Tables_DM -> TempSpecifiedDealer ->
FieldByName( "Amount" ) -> AsInteger =
               Tables_DM -> Temp -> FieldByName( "Amount" ) -> AsInteger;

               Tables_DM -> TempSpecifiedDealer -> Post();

               Tables_DM -> TempSpecifiedDealer -> Close();

            } // end if (0)

            // Tables_DM -> Temp would point to next record
            Tables_DM -> Temp -> Next();
         } // end while

         Tables_DM -> Temp -> Close();

file://---------------------------------------------------------------------
------

         // Print Dealer Monthly Account Statement

         // Only print the statement, if that Dealer is having record(s)
         if( iPrintStatementFlag == 1 ) // if( 18 )
         {
            PrintDealerStatement_F -> DateQL -> Caption =
            Date().FormatString( "dd-mm-yyyy" );

            PrintDealerStatement_F -> DealerNameQL -> Caption =
            Tables_DM -> DealerJSRec -> FieldByName ( "Name" ) -> AsString;

            // Uses for page's footer
            PrintDealerStatement_F -> qrlblDealerName -> Caption =
            Tables_DM -> DealerJSRec -> FieldByName ( "Name" ) -> AsString;

            PrintDealerStatement_F -> DealerContactNoQL -> Caption =
            Tables_DM -> DealerJSRec -> FieldByName ( "ContactNo" ) ->
AsString;

            // For TotalAmount generation
            Total = 0;

            Tables_DM -> TempSpecifiedDealer -> Open();
            Tables_DM -> TempSpecifiedDealer -> First();

            while( !Tables_DM -> TempSpecifiedDealer -> Eof )
            {
               Total += Tables_DM -> TempSpecifiedDealer ->
ieldByName( "Amount" ) -> AsInteger;
               Tables_DM -> TempSpecifiedDealer -> Next();
            }

            PrintDealerStatement_F -> TotalAmountQL -> Caption =
ntToStr( Total );

            // Make sure OwnerIgnore is ENABLED
            // OwnerIgnore is " Kindly make the necessary... " portion for
the print form
            if( PrintDealerStatement_F -> OwnerIgnore -> Enabled == false )
               PrintDealerStatement_F -> OwnerIgnore -> Enabled = true;

            PrintDealerStatement_F -> InvoiceCashSalesQL -> Caption =
"Invoice No";

            PrintDealerStatement_F -> DealerStatementQR -> Print();

            // Print first, close later
            Tables_DM -> TempSpecifiedDealer -> Close();

         }  // end if( 18 )

         // move to next record for further processing
         Tables_DM -> DealerJSRec -> Next();
      } // end for( 5 )

      // Close the table after for( 5 ) loop
      Tables_DM -> DealerJSRec -> Close();

// -=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-
// NO PROBLEM OCCURRED, IF I DISABLE THE CODES ABOVE

PLEASE HELP!

Regards,
ascll
as...@yahoo.com

Quote
Christian Bergthaller <ChrisB...@t-online.de> wrote in message

news:3b4f3724_2@dnews...
Quote

> "ascll" <as...@yahoo.com> schrieb im Newsbeitrag news:3b4ebfd2_2@dnews...

> > ........................
> > Invalid pointer operation ->Press Enter

> > The exception unknown software exception [0x0eedfade] occurred in the
> > application at location 0x77f1d479. -> Press Enter

> I guess it's something wrong somewhere with 'delete': e.g.  delete twice
or
> "delete" instead "delete[]" .

> Christian.

Re:Invalid pointer operation


A) This question belongs in either .database.* or .language.

B) If you reduce the problem to a compilable self-contained
program of 50 lines or less, people might actually look at
your code (I, for one, automatically skip over anything that
looks like more than 50 lines).

C) Chances are, if you accomplish B), you will probably find
the problem (and maybe even the solution) yourself. ;)

Dave

Other Threads