Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 7 of 7 total |
problem with TEDBDatabase.StartTransaction |
Tue, Mar 19 2013 2:14 AM | Permanent Link |
Adam H. | Hi,
I was wondering if anyone can see any problem with the following: EDBDatabase1.StartTranscation(['MyTable']) The error I'm getting is at runtime, which states: Exception class EDatabaseError with message 'Invalid table name passed to StartTransaction in Position 0'. Cheers Adam |
Tue, Mar 19 2013 3:12 AM | Permanent Link |
Adam H. | I've managed to get around it by creating my own custom procedure as
follows: procedure EDBStartTransaction(Database : TEdbDatabase; Tables : Array of String); var EDBTables: TEDBStringsArray; i : integer; begin setlength(EDBTables, length(tables)); for i := 0 to Length(Tables) - 1 do EDBTables[0] := Tables[i]; Database.StartTransaction(EDBTables); end; Then I can simply call one line of code as such: EDBStartTransaction(Mainform.DB, ['Emailmessages']); Just looking to try and simplify transactions to a single line of code each time I use them. I can't figure out since EDBStringarrays are just arrays of TEDBString which is just an AnsiString why my original attempt failed. Cheers Adam. |
Tue, Mar 19 2013 12:40 PM | Permanent Link |
Raul Team Elevate | On 3/19/2013 3:12 AM, Adam H. wrote:
> I can't figure out since EDBStringarrays are just arrays of TEDBString > which is just an AnsiString why my original attempt failed. Adam, All i can think of is casting. I wonder if following works : EDBDatabase1.StartTranscation(TEDBStringsArray(['MyTable'])) or Database.StartTransaction(TEDBStringsArray(EDBTables)); Raul |
Tue, Mar 19 2013 4:05 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Adam,
<< The error I'm getting is at runtime, which states: Exception class EDatabaseError with message 'Invalid table name passed to StartTransaction in Position 0'. >> Is this Unicode, and if so, what version of Delphi ? There may be an issue in the constant array version of StartTransaction: procedure TEDBDatabase.StartTransaction(const Tables: array of const; Timeout: Integer=-1); var I: Integer; TempArray: TEDBStringsArray; begin SetLength(TempArray,(High(Tables)+1)); for I:=Low(Tables) to High(Tables) do begin case Tables[I].VType of vtString: TempArray[I]:=pEDBChar(Tables[I].VString); vtAnsiString: TempArray[I]:=pAnsiChar(Tables[I].VAnsiString); vtWideString: TempArray[I]:=pWideChar(Tables[I].VWideString); else DatabaseErrorFmt(STransTableError,[IntToStr(I)]); <<<<< The type of the constant array element is something unexpected end; end; StartTransaction(TempArray,Timeout); end; It should probably look like this for later versions of Delphi: procedure TEDBDatabase.StartTransaction(const Tables: array of const; Timeout: Integer=-1); var I: Integer; TempArray: TEDBStringsArray; begin SetLength(TempArray,(High(Tables)+1)); for I:=Low(Tables) to High(Tables) do begin case Tables[I].VType of vtString: TempArray[I]:=pEDBChar(Tables[I].VString); vtAnsiString: TempArray[I]:=pAnsiChar(Tables[I].VAnsiString); vtWideString: TempArray[I]:=pWideChar(Tables[I].VWideString); {$IFDEF D12ORHIGHER} vtUnicodeString: TempArray[I]:=pWideChar(Tables[I].VUnicodeString); {$ENDIF} else DatabaseErrorFmt(STransTableError,[IntToStr(I)]); end; end; StartTransaction(TempArray,Timeout); end; You should be able to work around this by doing this: EDBDatabase1.StartTranscation([WideString('MyTable')]) or EDBDatabase1.StartTranscation([AnsiString('MyTable')]) I'll have a fix for this in the next build. Tim Young Elevate Software www.elevatesoft.com |
Tue, Mar 19 2013 4:06 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | |
Tue, Mar 19 2013 5:15 PM | Permanent Link |
Adam H. | Hi Tim,
> I'll have a fix for this in the next build. Thanks for that! Greatly appreciated. Cheers Adam. |
Tue, Mar 19 2013 5:15 PM | Permanent Link |
Adam H. | Thanks for your reply Raul.
Looks like according to Tim that there may be a change (fix) for this in the next build, and he'd given me a copy of what it should look like so I can correct it my end. Appreciate the time you took to reply! Cheers Adam. |
This web page was last updated on Monday, April 29, 2024 at 05:23 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |