Why I'm getting access violation when calling <DatasetDescendant>.FieldDefs.Find() ?

Hi,

I'm getting access violation when calling <DatasetDescendant>.FieldDefs.Find();
Here is my Code :
      fsScript1.Clear;
      fsScript1.AddClass(TMyConnection, 'TCustomMyConnection');
      fsScript1.AddClass(TCustomMyConnection, 'TCustomDAConnection');
      fsScript1.AddClass(TCustomDAConnection, 'TCustomConnection');
      fsScript1.AddClass(TCustomConnection, 'TComponent');
      fsScript1.AddObject('MyConnection', AMyConnection);

      fsScript1.AddClass(TMyQuery, 'TCustomMyDataSet');
      fsScript1.AddClass(TCustomMyDataSet, 'TCustomDADataSet');
      fsScript1.AddClass(TCustomDADataSet, 'TMemDataSet');
      fsScript1.AddClass(TMemDataSet, 'TDataset');
      fsScript1.AddObject('Table',MyQuery);

       fsScript1.Lines.Text:= PasclScript;
      fsScript1.Parent := fsGlobalUnit; // use standard classes and methods
      fsScript1.SyntaxType := 'PascalScript';
      if fsScript1.Compile then
      fsScript1.Execute else
      ShowMessage(fsScript1.ErrorMsg);

My PascalScript looks like this :
If Table.FieldDefs.Find('User') <> nil then  Table.Fieldbyname('User').AsString := MyConnection.username;

When executing it, I'm getting an access violation. Debugger stops in fs_idbrtti , function TFunctions.GetProp where TDataSet(Instance) is always nil ?

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.