Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 10 of 11 total |
Access Violation using TDBISamQuery.Add |
Thu, Jul 26 2012 9:05 PM | Permanent Link |
Adam H. | Hi,
I've just hit a very unusual situation within my application where it is raising an access violation. I have the following code: function TDmCommonChecks.GetNameIDFromABBCode(ABBCode : String): String; var s : String; begin if not assigned(DMCommonChecks) then Application.CreateForm(TDMCommonChecks, DMCommonChecks); result := ''; DMCommonChecks.CustomQ.close; DMCommonChecks.customQ.sql.clear; s := 'Select ID from Names where (ABBCD = '+Quotedstr(ABBCode)+')'; DMCommonChecks.customQ.sql.add(s); //<<<<<<<<<<<<<<<<<<<<AV DMCommonChecks.CustomQ.open; ...... I'm getting an access violation here whenever I try to add to the SQL property. I can use SQL.CLEAR, but I can't use SQL.ADD, nor SQL.LOADFROMFILE It doesn't seem to matter what string I try to add in there, it AV's every time. This has got me quite confused, considering that everything up to this point behaves correctly. Does anyone know what might be causing a problem trying to assign a string to the SQL property? Thanks & Regards Adam. |
Thu, Jul 26 2012 9:20 PM | Permanent Link |
Adam H. | To add to the confusion, this particular unit is part of another
application. (Shared unit). It works fine in the original application, but it's not working properly in my new application. > Hi, > > I've just hit a very unusual situation within my application where it is > raising an access violation. > > I have the following code: > > function TDmCommonChecks.GetNameIDFromABBCode(ABBCode : String): String; > var > s : String; > begin > if not assigned(DMCommonChecks) then > Application.CreateForm(TDMCommonChecks, DMCommonChecks); > result := ''; > DMCommonChecks.CustomQ.close; > DMCommonChecks.customQ.sql.clear; > s := 'Select ID from Names where (ABBCD = '+Quotedstr(ABBCode)+')'; > DMCommonChecks.customQ.sql.add(s); //<<<<<<<<<<<<<<<<<<<<AV > DMCommonChecks.CustomQ.open; > ..... > > I'm getting an access violation here whenever I try to add to the SQL > property. I can use SQL.CLEAR, but I can't use SQL.ADD, nor > SQL.LOADFROMFILE > > It doesn't seem to matter what string I try to add in there, it AV's > every time. > > This has got me quite confused, considering that everything up to this > point behaves correctly. > > Does anyone know what might be causing a problem trying to assign a > string to the SQL property? > > Thanks & Regards > > Adam. |
Thu, Jul 26 2012 9:36 PM | Permanent Link |
Adam H. | Nevermind... it appears as though it's not DBISam at all - because other
'shared' forms are also experiencing the same problem with TStrings (such as memo objects)... The weirdness continues. :-/ On 27/07/2012 11:20 AM, Adam H. wrote: > To add to the confusion, this particular unit is part of another > application. (Shared unit). It works fine in the original application, > but it's not working properly in my new application. > > >> Hi, >> >> I've just hit a very unusual situation within my application where it is >> raising an access violation. >> >> I have the following code: >> >> function TDmCommonChecks.GetNameIDFromABBCode(ABBCode : String): String; >> var >> s : String; >> begin >> if not assigned(DMCommonChecks) then >> Application.CreateForm(TDMCommonChecks, DMCommonChecks); >> result := ''; >> DMCommonChecks.CustomQ.close; >> DMCommonChecks.customQ.sql.clear; >> s := 'Select ID from Names where (ABBCD = '+Quotedstr(ABBCode)+')'; >> DMCommonChecks.customQ.sql.add(s); //<<<<<<<<<<<<<<<<<<<<AV >> DMCommonChecks.CustomQ.open; >> ..... >> >> I'm getting an access violation here whenever I try to add to the SQL >> property. I can use SQL.CLEAR, but I can't use SQL.ADD, nor >> SQL.LOADFROMFILE >> >> It doesn't seem to matter what string I try to add in there, it AV's >> every time. >> >> This has got me quite confused, considering that everything up to this >> point behaves correctly. >> >> Does anyone know what might be causing a problem trying to assign a >> string to the SQL property? >> >> Thanks & Regards >> >> Adam. > |
Fri, Jul 27 2012 9:42 AM | Permanent Link |
Raul Team Elevate | Just a suggestion but why are you using CreateForm?!
why not just DMCommonChecks := TDMCommonChecks.Create ? Raul On 7/26/2012 9:05 PM, Adam H. wrote: > Hi, > > I've just hit a very unusual situation within my application where it is > raising an access violation. > > I have the following code: > > function TDmCommonChecks.GetNameIDFromABBCode(ABBCode : String): String; > var > s : String; > begin > if not assigned(DMCommonChecks) then > Application.CreateForm(TDMCommonChecks, DMCommonChecks); > result := ''; > DMCommonChecks.CustomQ.close; > DMCommonChecks.customQ.sql.clear; > s := 'Select ID from Names where (ABBCD = '+Quotedstr(ABBCode)+')'; > DMCommonChecks.customQ.sql.add(s); //<<<<<<<<<<<<<<<<<<<<AV > DMCommonChecks.CustomQ.open; > ..... > > I'm getting an access violation here whenever I try to add to the SQL > property. I can use SQL.CLEAR, but I can't use SQL.ADD, nor > SQL.LOADFROMFILE > > It doesn't seem to matter what string I try to add in there, it AV's > every time. > > This has got me quite confused, considering that everything up to this > point behaves correctly. > > Does anyone know what might be causing a problem trying to assign a > string to the SQL property? > > Thanks & Regards > > Adam. |
Sun, Jul 29 2012 7:14 PM | Permanent Link |
Adam H. | Good Morning Raul,
Good question. It's something I've been using for the last decade - probably something I learned (incorrectly?) and have stuck with. Is there much difference between the two? Cheers Adam. > Just a suggestion but why are you using CreateForm?! > > why not just DMCommonChecks := TDMCommonChecks.Create ? > > > Raul > > > > On 7/26/2012 9:05 PM, Adam H. wrote: >> Hi, >> >> I've just hit a very unusual situation within my application where it is >> raising an access violation. >> >> I have the following code: >> >> function TDmCommonChecks.GetNameIDFromABBCode(ABBCode : String): String; >> var >> s : String; >> begin >> if not assigned(DMCommonChecks) then >> Application.CreateForm(TDMCommonChecks, DMCommonChecks); >> result := ''; >> DMCommonChecks.CustomQ.close; >> DMCommonChecks.customQ.sql.clear; >> s := 'Select ID from Names where (ABBCD = '+Quotedstr(ABBCode)+')'; >> DMCommonChecks.customQ.sql.add(s); //<<<<<<<<<<<<<<<<<<<<AV >> DMCommonChecks.CustomQ.open; >> ..... >> >> I'm getting an access violation here whenever I try to add to the SQL >> property. I can use SQL.CLEAR, but I can't use SQL.ADD, nor >> SQL.LOADFROMFILE >> >> It doesn't seem to matter what string I try to add in there, it AV's >> every time. >> >> This has got me quite confused, considering that everything up to this >> point behaves correctly. >> >> Does anyone know what might be causing a problem trying to assign a >> string to the SQL property? >> >> Thanks & Regards >> >> Adam. > |
Mon, Jul 30 2012 10:13 AM | Permanent Link |
Raul Team Elevate | Adam,
There is definitely nothing wrong with it - IDE uses it. There are some small limitations - 1st form created becomes the app main window and application is the owner of the form. However what you described (TStrings not getting created) looks like a init issue so i always try to simplify things to narrow it down is all. Either you init routines are not running properly (inherited not called somewhere?) or otherwise smething is freeing the form variables. Raul On 7/29/2012 7:14 PM, Adam H. wrote: > Good Morning Raul, > > Good question. It's something I've been using for the last decade - > probably something I learned (incorrectly?) and have stuck with. > > Is there much difference between the two? > > Cheers > > Adam. > >> Just a suggestion but why are you using CreateForm?! >> >> why not just DMCommonChecks := TDMCommonChecks.Create ? >> >> >> Raul |
Mon, Jul 30 2012 2:08 PM | Permanent Link |
Fernando Dias Team Elevate | Adam,
This function is confusing me... When are you calling it, from where? You are creating the form inside a function that is a method of the form you are creating... -- Fernando Dias [Team Elevate] |
Mon, Jul 30 2012 11:09 PM | Permanent Link |
Adam H. | Hi Raul,
The problem ended up being involved with an inherited form. They were two separate units and forms. I'm not sure exactly where, but when I copied the original ancestor form to the new project, it behaved fine! Thanks for your help! Cheers Adam. > Adam, > > There is definitely nothing wrong with it - IDE uses it. There are some > small limitations - 1st form created becomes the app main window and > application is the owner of the form. > > However what you described (TStrings not getting created) looks like a > init issue so i always try to simplify things to narrow it down is all. > > Either you init routines are not running properly (inherited not called > somewhere?) or otherwise smething is freeing the form variables. > > Raul > > On 7/29/2012 7:14 PM, Adam H. wrote: >> Good Morning Raul, >> >> Good question. It's something I've been using for the last decade - >> probably something I learned (incorrectly?) and have stuck with. >> >> Is there much difference between the two? >> >> Cheers >> >> Adam. >> >>> Just a suggestion but why are you using CreateForm?! >>> >>> why not just DMCommonChecks := TDMCommonChecks.Create ? >>> >>> >>> Raul > |
Wed, Aug 1 2012 2:45 AM | Permanent Link |
Adam H. | Hi Fernando,
Correct. It's effectively a function that uses a code to return a GUID field. This function is used all over the project in many areas. So I only need to call the function once, without creating code to create and destroy the form in every unit that calls the function (Could be 40 or more different units), I've placed it all in the one area. I could have two separate units I suppose - one where the code is outside the form that contains the query / components - but this seems to be working fine, and simplifies things. (Everything is in the one location). HTH Adam. On 31/07/2012 4:08 AM, Fernando Dias wrote: > Adam, > > This function is confusing me... When are you calling it, from where? > You are creating the form inside a function that is a method of the form > you are creating... > > > -- > Fernando Dias > [Team Elevate] |
Wed, Aug 1 2012 4:51 AM | Permanent Link |
Fernando Dias Team Elevate | Adam,
Ah, it's declared as a class method, right? Fernando Dias [Team Elevate] |
Page 1 of 2 | Next Page » | |
Jump to Page: 1 2 |
This web page was last updated on Saturday, April 27, 2024 at 08:52 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |