Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9007841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:47:53+00:00 2026-06-16T01:47:53+00:00

I wrote the following code by serialization and a deserialization of forms and their

  • 0

I wrote the following code by serialization and a deserialization of forms and their contents to Delphi

unit SerAndDeser;

interface

  uses Classes,MainForm,ListOfTables,DataOfTable,SerialForms,sysutils,ActiveX, DatabaseClasses, UnloadProcs;

  procedure Ser();
  procedure Deser();
  function GetGUID(): string;
  function DeleteSymbols(inputstr : string) : string;
implementation

  function GetGUID(): string;
  var
  GUID : TGUID;
  begin
  Result := '';
  if CoCreateGuid(GUID) = 0 then
    Result := GUIDToString(GUID);
    Result := StringReplace(Result, '{', '', []);
    Result := StringReplace(Result, '}', '', []);
    Result := StringReplace(Result, '-', '', [rfReplaceAll]);
  end;

  function DeleteSymbols(inputstr : string): string;
  begin
  Result := '';
    Result := StringReplace(inputstr, '-', '', [rfReplaceAll]);
    Result := StringReplace(Result, ' ', '', [rfReplaceAll]);
    Result := StringReplace(Result, '\', '', [rfReplaceAll]);
    Result := StringReplace(Result, '/', '', [rfReplaceAll]);
  end;

  procedure Ser();

    var mForm : MainFormInfo;
        tForm : TableFormInfo;
        lForm : ListFormInfo;
        tempFmtable : TfmTableData;
        i,j : integer;
        MyFileStream : TFileStream;
        MyMemoryStream : TMemoryStream;
        field : TableFieldInfo;
  begin
        try
      mForm := nil;

      mForm := MainFormInfo.Create(
        nil,
        MainWindow.Left,
        MainWindow.Top,
        MainWindow.Height,
        MainWindow.Width,
        MainWindow.partofconnectstring,
        MainWindow.dbname,
        MainWindow.dbfilename);
      mForm.Name := 'MainWindow';

      //table forms
      try
        tForm := nil;
        field := nil;

        for i := 0 to MainWindow.ComponentCount - 1 do
          if (MainWindow.Components[i] is TfmTableData) then
            begin
              tempFmtable := MainWindow.Components[i] as TfmTableData;
              tForm := TableFormInfo.Create(
                mForm,
                tempFmtable.Left,
                tempFmtable.Top,
                tempFmtable.Height,
                tempFmtable.Width,
                tempFmtable.tname);
              tForm.Name := tempFmtable.Name;

              //fields
              for j := 0 to tempFmtable.DBGrid1.Columns.Count - 1 do
              begin
                field := nil;

                field := TableFieldInfo.Create(
                  tForm,
                  tempFmtable.DBGrid1.Columns[j].FieldName,
                  tempFmtable.DBGrid1.Columns[j].Title.Caption,
                  tempFmtable.DBGrid1.Columns[j].Index,
                  tempFmtable.DBGrid1.Columns[j].Visible);
                  field.Name := DeleteSymbols(tempFmtable.DBGrid1.Columns[j].FieldName);{tempFmtable.DBGrid1.Columns[j].FieldName} {+ GetGUID;}
              end;
              //

            end;
      except
        field.Free;
        tForm.Free;
      end;
      //

      //List form
      try
        lForm := nil;
        lForm := ListFormInfo.Create(
          mForm,
          fmListOfTables.Left,
          fmListOfTables.Top,
          fmListOfTables.Height,
          fmListOfTables.Width);
        lForm.Name := 'fmListOfTables';
      except
        lForm.Free;
      end;
      //

      //save
      MyFileStream := nil;
      MyMemoryStream := nil;

      MyFileStream := TFileStream.Create('test.txt', fmCreate);
      MyMemoryStream := TMemoryStream.Create;
      MyMemoryStream.WriteComponent(mForm);
      MyMemoryStream.Position := 0;
      ObjectBinaryToText(MyMemoryStream,MyFileStream);
      MainWindow.Panel1.DockManager.SaveToStream(MyFileStream);
      //

    finally
      mForm.Free;
      MyFileStream.Free;
      MyMemoryStream.Free;
    end;
  end;


  procedure Deser();

    var mForm : MainFormInfo;
        tForm : TableFormInfo;
        lForm : ListFormInfo;
        tempFmtable : TfmTableData;
        i,j : integer;
        MyFileStream : TFileStream;
        MyMemoryStream : TMemoryStream;
        table : TTableSpec;
        descr : string;
        field : TableFieldInfo;


  begin
    try
      //destroy environment
      i := 0;
      while (i <= MainWindow.ComponentCount - 1) do
      begin
        if MainWindow.Components[i] is TfmTableData then
          try
            tempFmTable := nil;
            tempFmTable := MainWindow.Components[i] as TfmTableData;
            tempFmTable.IBQuery1.Close;
            tempFmtable.Free;
          except
            tempFmTable.Free;
          end
        else
          inc(i);
      end;
      fmListOfTables.Free;
      DBSchema.Free;
      //

      //read
      mForm := nil;
      MyFileStream := nil;
      MyMemoryStream := nil;

      mForm := MainFormInfo.Create(nil, -1, -1, -1, -1, MainWindow.partofconnectstring, MainWindow.dbname, MainWindow.dbfilename);

      MyFileStream := TFileStream.Create('test.txt', fmOpenRead);
      MyMemoryStream := TMemoryStream.Create;
      ObjectTextToBinary(MyFileStream,MyMemoryStream);
      MyMemoryStream.Position := 0;
      MyMemoryStream.ReadComponent(mForm);
      //

      //go
      UnloadProcs.ConnectToDatabase(MainWindow.partofconnectstring, MainWindow.SQLConnection1);
      //UnloadProcs.CreateObjs(MainWindow.SQLConnection1, MainForm.DBSchema);
      //fmListOfTables.Show;

      MainWindow.Left := mForm.LeftValue;
      MainWindow.Top := mForm.TopValue;
      MainWindow.Height := mForm.HeightValue;
      MainWindow.Width := mForm.WidthValue;

      //list
      i := 0;
      while i <= mForm.ComponentCount - 1 do
      begin
        if mForm.Components[i] is ListFormInfo then
          try
            lForm := nil;
            lForm := mForm.Components[i] as ListFormInfo;
            fmListOfTables.Left := lForm.LeftValue;
            fmListOfTables.Top := lForm.TopValue;
            fmListOfTables.Height := lForm.HeightValue;
            fmListOfTables.Width := lForm.WidthValue;
            fmListOfTables.Show;
            inc(i);
          finally
            lForm.Free;
          end
        else
          inc(i);
      end;
      //

      //fmListOfTables.Show;
      //tables
      for j := 0 to mForm.ComponentCount - 1 do
        if mForm.Components[j] is TableFormInfo then
          try
            table := nil;
            tempFmtable := nil;
            tForm := nil;

            tForm := mForm.Components[j] as TableFormInfo;

            table := TTableSpec(DBSchema.Tables.FindComponent(tForm.Table));
            tempFmtable := TfmTableData.Create(MainWindow);
            tempFmtable.Name := tForm.Name;
            tempFmtable.tname := tForm.Table;
            //tempFmtable.Caption := Utf8ToAnsi(table.Description);
            tempFmtable.Left := tForm.LeftValue;
            tempFmtable.Top := tForm.TopValue;
            tempFmtable.Height := tForm.HeightValue;
            tempFmtable.Width := tForm.WidthValue;

            tempFmTable.IBQuery1.SQL.Clear;
            tempFmtable.IBQuery1.SQL.Add('select * from ' + table.Name);
            tempFmtable.IBQuery1.Open;

            i := 0;
            while i <= tForm.ComponentCount - 1 do
              if tForm.Components[i] is TableFieldInfo then
              begin
                field := nil;

                field := tForm.Components[i] as TableFieldInfo;
                tempFmtable.DBGrid1.Columns[i].FieldName := field.FieldNameValue;
                tempFmtable.DBGrid1.Columns[i].Title.Caption := field.DescriptionValue;
                tempFmtable.DBGrid1.Columns[i].Index := field.IndexValue;
                tempFmtable.DBGrid1.Columns[i].Visible := field.VisibleValue;
                //tempFmtable.CheckListBox1.Items.Add(field.Description);
                //tempFmtable.CheckListBox1.Checked[i] := field.Visible;
                inc(i);
              end
              else
                inc(i);

            {for i := 0 to table.Fields.ComponentCount - 1 do
            begin
              descr := Utf8ToAnsi(((table.Fields.Components[i]) as TFieldSpec).Description);
              tempFmtable.CheckListBox1.Items.Add(descr);
              tempFmtable.DBGrid1.Columns[i].Title.Caption := descr;
              tempFmtable.CheckListBox1.Checked[i] := true;
            end; }

            tempFmtable.Show;


          except
            tempFmtable.Free;
            tForm.Free;
            table.Free;
          end;
      //

      //dock
      MainWindow.Panel1.DockManager.BeginUpdate;
      MainWindow.Panel1.DockManager.LoadFromStream(MyFileStream);
      MainWindow.Panel1.DockManager.ResetBounds(TRUE);
      MainWindow.Panel1.DockManager.EndUpdate;


      //
    finally
      MyFileStream.Free;
      MyMemoryStream.Free;
    end;

  end;

end.

When debugging I found out that gives out

'Project GUI.exe raised exception class $C0000005 with message 'access violation at 0x00821dae: read of address 0x00000044'. 

exception at line

tempFmtable.IBQuery1.SQL.Add('select * from ' + table.Name);

in the following block of a code from a code is higher

  //tables
  for j := 0 to mForm.ComponentCount - 1 do
    if mForm.Components[j] is TableFormInfo then
      try
        table := nil;
        tempFmtable := nil;
        tForm := nil;

        tForm := mForm.Components[j] as TableFormInfo;

        table := TTableSpec(DBSchema.Tables.FindComponent(tForm.Table));
        tempFmtable := TfmTableData.Create(MainWindow);
        tempFmtable.Name := tForm.Name;
        tempFmtable.tname := tForm.Table;
        //tempFmtable.Caption := Utf8ToAnsi(table.Description);
        tempFmtable.Left := tForm.LeftValue;
        tempFmtable.Top := tForm.TopValue;
        tempFmtable.Height := tForm.HeightValue;
        tempFmtable.Width := tForm.WidthValue;

        tempFmTable.IBQuery1.SQL.Clear;
        tempFmtable.IBQuery1.SQL.Add('select * from ' + table.Name);
        tempFmtable.IBQuery1.Open;

        i := 0;
        while i <= tForm.ComponentCount - 1 do
          if tForm.Components[i] is TableFieldInfo then
          begin
            field := nil;
            //tempFmtable.Show;
            field := tForm.Components[i] as TableFieldInfo;
            tempFmtable.DBGrid1.Columns[i].FieldName := field.FieldNameValue;
            tempFmtable.DBGrid1.Columns[i].Title.Caption := field.DescriptionValue;
            tempFmtable.DBGrid1.Columns[i].Index := field.IndexValue;
            tempFmtable.DBGrid1.Columns[i].Visible := field.VisibleValue;
            //tempFmtable.CheckListBox1.Items.Add(field.Description);
            //tempFmtable.CheckListBox1.Checked[i] := field.Visible;
            //tempFmtable.Show;
            inc(i);
          end
          else
            inc(i);

        {for i := 0 to table.Fields.ComponentCount - 1 do
        begin
          descr := Utf8ToAnsi(((table.Fields.Components[i]) as TFieldSpec).Description);
          tempFmtable.CheckListBox1.Items.Add(descr);
          tempFmtable.DBGrid1.Columns[i].Title.Caption := descr;
          tempFmtable.CheckListBox1.Checked[i] := true;
        end; }

        tempFmtable.Show;


      except
        tempFmtable.Free;
        tForm.Free;
        table.Free;
      end;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:47:54+00:00Added an answer on June 16, 2026 at 1:47 am

    The line that fails is:

    tempFmtable.IBQuery1.SQL.Add('select * from ' + table.Name);
    

    Before this line runs you assigned table like this:

    table := TTableSpec(DBSchema.Tables.FindComponent(tForm.Table));
    

    It would seem that FindComponent returned nil.

    As I’m sure you know, you have to have a valid object instance in order to call methods, access fields and properties etc. Your code should check for this condition and respond accordingly.

    You can see all this quite readily in the debugger. The debugger will break on that line and when you inspect the variables it will tell you that table is nil. Then you have to look at the code and work out why. I recommend that you spend some time improving your debugging skills and learning how to use the tools available.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote the following code by serialization and a deserialization of forms and their
i wrote following code to create a linkbutton programmatically, but its showing like lable
I wrote following code...but i am getting Error like: Error 1 'LoginDLL.Class1.Login(string, string, string)':
I wrote the following code for text file encryption and decryption. The encryption process
I wrote the following code to select text from database,but when i echo the
if wrote the following code and do not understand why the trace returns false:
I wrote the following code: import java.lang.*; import DB.*; private Boolean validateInvoice(String i) {
I wrote the following code snippet in VS2010: #pragma once #include stdafx.h #ifndef SECURITY_WIN32
I wrote the following code to count the node of an XML file: private
I wrote the following code to rotate a cube on x axis an entire

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.