Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 8 of 8 total |
Problem with Memory Table. |
Wed, Sep 20 2006 12:42 AM | Permanent Link |
Steve Gill | I'm doing something wrong with a memory table but I don't know what. I
have a method that uses a TDBISAMTable as a memory table. The first time the method runs it works fine, however, the second time I get an "DBISAM Error 11010 Table or backup file 'Codes.dat' does not exist" error when it tries to define the fields. Here's a sample of the code with all of the irrelevant bits removed: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - tblCodes.DatabaseName := 'Memory'; tblCodes.TableName := 'Codes'; // Error occurs on this next line on the second run through tblCodes.FieldDefs.Add('Code', ftString, 20, False, '', '', '', '', fcNoChange, 0); tblCodes.FieldDefs.Add('CodeName', ftString, 60, False, '', '', '', '', fcNoChange, 0); tblCodes.CreateTable; tblCodes.Open; // Do a whole lot of boring stuff tblCodes.Close; tblCodes.DeleteTable; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - It's probably something really stupid that I'm missing (as usual). Delphi 7 DBISAM 4.24 Build 1 Thanks. Regards, SteveG |
Wed, Sep 20 2006 12:15 PM | Permanent Link |
Abdulaziz Jasser | You need to free it:
tblCodes.Close; tblCodes.DeleteTable; tblCodes.Free; //You need to free it. |
Wed, Sep 20 2006 4:48 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Steve,
<< I'm doing something wrong with a memory table but I don't know what. I have a method that uses a TDBISAMTable as a memory table. The first time the method runs it works fine, however, the second time I get an DBISAM Error 11010 Table or backup file 'Codes.dat' does not exist" error when it tries to define the fields. >> I don't know what is going on. A FieldDefs.Add() shouldn't do anything in terms of opening the table, etc., so it shouldn't cause that error. I ran the following here: procedure TForm1.Button1Click(Sender: TObject); begin dbisamtable1.DatabaseName := 'Memory'; dbisamtable1.TableName := 'Codes'; // Error occurs on this next line on the second run through dbisamtable1.FieldDefs.Clear; dbisamtable1.FieldDefs.Add('Code', ftString, 20, False, '', '', '', '', fcNoChange, 0); dbisamtable1.FieldDefs.Add('CodeName', ftString, 60, False, '', '', '', '', fcNoChange, 0); dbisamtable1.CreateTable; dbisamtable1.Open; // Do a whole lot of boring stuff dbisamtable1.Close; dbisamtable1.DeleteTable; end; many times in succession and it worked fine. I had to add the FieldDefs.Clear call, or else you'll get an error about 'Code' already being defined. -- Tim Young Elevate Software www.elevatesoft.com |
Wed, Sep 20 2006 6:55 PM | Permanent Link |
Steve Gill | Hi Abdulaziz,
> You need to free it: > > tblCodes.Close; > tblCodes.DeleteTable; > tblCodes.Free; //You need to free it. Thanks for the suggestion. In this case though it shouldn't be freed because tblCodes is a component on the form. Regards, Steve |
Wed, Sep 20 2006 7:00 PM | Permanent Link |
Steve Gill | Hi Tim,
> I don't know what is going on. A FieldDefs.Add() shouldn't do anything in > terms of opening the table, etc., so it shouldn't cause that error. > > I ran the following here: > > procedure TForm1.Button1Click(Sender: TObject); > begin > dbisamtable1.DatabaseName := 'Memory'; > dbisamtable1.TableName := 'Codes'; > > // Error occurs on this next line on the second run through > dbisamtable1.FieldDefs.Clear; > dbisamtable1.FieldDefs.Add('Code', ftString, 20, False, '', '', '', '', > fcNoChange, 0); > dbisamtable1.FieldDefs.Add('CodeName', ftString, 60, False, '', '', '', '', > fcNoChange, 0); > > dbisamtable1.CreateTable; > dbisamtable1.Open; > > // Do a whole lot of boring stuff > > dbisamtable1.Close; > dbisamtable1.DeleteTable; > end; > > many times in succession and it worked fine. I had to add the > FieldDefs.Clear call, or else you'll get an error about 'Code' already being > defined. > Yeah, I'm not sure what's going on either. I got around it by creating the table component dynamically each time the method is run. When I get some more time I'll play with it some more to see if I can work out what's going on. Regards, Steve |
Thu, Sep 21 2006 5:51 PM | Permanent Link |
Abdulaziz Jasser | I am not done yet. I can see that you are creating the same table again and again. More to say, you are adding the same field's definition every
time. Maybe you should look ate that. |
Thu, Sep 21 2006 6:46 PM | Permanent Link |
Steve Gill | Abdulaziz Jasser wrote:
> I am not done yet. I can see that you are creating the same table again and again. More to say, you are adding the same field's definition every > time. Maybe you should look ate that. Sorry Abdulaziz, I don't quite understand your point. As the table is a component on the form, it is created when the form is created and freed when the form is destroyed. The DeleteTable method destroys the table in memory. The only time I would need to free it would be if I was creating the table dynamically. I actually tried clearing the field definitions before adding them but it made no difference. I think something weird is going on with the form because the same code works fine in another application. I changed the code in this application so that it creates the table dynamically and it now works. When I get time (this is a multi-million dollar project with tight deadlines) I will try re-creating the form from scratch and see if I can work out what the problem is. Regards, SteveG |
Thu, Sep 21 2006 7:10 PM | Permanent Link |
"Robert" | "Steve Gill" <v8steve@gmail.com> wrote in message news:7E9CB84A-3B63-4D66-8466-68E8AF77D68C@news.elevatesoft.com... This seems to work. One would think that a DeleteTable implies a FieldDefs.Clear. One would be wrong. Robert tblCodes.DatabaseName := 'Memory'; tblCodes.TableName := 'Codes'; if tblCodes.Exists then begin tblCodes.Close; tblCodes.FieldDefs.Clear; tblCodes.DeleteTable; end; tblCodes.FieldDefs.Add('Code', ftString, 20, False, '', '', '', '', fcNoChange, 0); tblCodes.FieldDefs.Add('CodeName', ftString, 60, False, '', '', '', '', fcNoChange, 0); tblCodes.CreateTable; tblCodes.Open; // Do a whole lot of boring stuff tblCodes.Close; |
This web page was last updated on Saturday, May 4, 2024 at 12:54 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |