procedure TZSQLiteBaseDriver.LoadCodePages; //Egonhugeist begin { MultiByte } AddCodePage('UTF-8', 1, ceUTF8, zCP_UTF8); AddCodePage('UTF-16le', 2, ceUTF16, zCP_UTF16, 'UTF-8'); //Setting this will be ignored by actual Excute of Plaindriver AddCodePage('UTF-16be', 3, ceUTF16, zCP_UTF16BE, 'UTF-8'); //Setting this will be ignored by actual Excute of Plaindriver AddCodePage('UTF-16', 4, ceUTF16, zCP_UTF16, 'UTF-8'); //Setting this will be ignored by actual Excute of Plaindriver AddCodePage('GBK', 3, ceAnsi, 936); {GB2312-80 Simplified Chinese} end;
procedure TZSQLiteConnection.Open; var ErrorCode: Integer; ErrorMessage: PAnsiChar; LogMessage: string; SQL: AnsiString; Timeout_ms: Integer; begin if not Closed then Exit; ErrorMessage := '';
LogMessage := Format('CONNECT TO "%s" AS USER "%s"', [Database, User]);
if FHandle = nil then begin CheckSQLiteError(GetPlainDriver, FHandle, SQLITE_ERROR, ErrorMessage, lcConnect, LogMessage); end; DriverManager.LogMessage(lcConnect, PlainDriver.GetProtocol, LogMessage);
{ Turn on encryption if requested } if StrToBoolEx(Info.Values['encrypted']) then begin {$IFDEF UNICODE} ErrorCode := GetPlainDriver.Key(FHandle, PAnsiChar(UTF8String(Password)), {$IFDEF WITH_STRLEN_DEPRECATED}AnsiStrings.{$ENDIF}StrLen(PAnsiChar(UTF8String(Password)))); {$ELSE} ErrorCode := GetPlainDriver.Key(FHandle, PAnsiChar(Password), StrLen(PAnsiChar(Password))); {$ENDIF} CheckSQLiteError(GetPlainDriver, FHandle, ErrorCode, nil, lcConnect, 'SQLite.Key'); end;
{ Set busy timeout if requested } Timeout_ms := StrToIntDef(Info.Values['busytimeout'], -1); if Timeout_ms >= 0 then begin GetPlainDriver.BusyTimeout(FHandle, Timeout_ms); end;