#51 Re: mORMot 1 » Show DynArry with DrawGrid » 2014-05-30 11:04:11

I tryed to serialize the DynArry as JSON but I get a Base64 string, I read the documentation but I don't understand how to do the conversion.

var json : RawUtf8;
    inv : TSQLInvoice;
    invDets : TInvoiceRecs;
begin
...
  try
    inv := := TSQLInvoice.CreateJoined(globalClient, fRec.ID); 
    invDets := inv.Details;    <----------------- No Base64
    TTextWriter.RegisterCustomJSONSerializer(TypeInfo(TInvoiceRecs), nil, nil);
    json := DynArraySaveJSON(invDets, TypeInfo(TInvoiceRecs));  <--------------- Base64
  finally
    inv.free;
  end;
...

Another question :
I added a TSQLArticle property into TInvoiceRec and some others, that works fine when adding records but when I try to load/retrieve the article information I got AV, should I retrieve true instances like with FillPrepareMany for TSQLRecordMany?

type
  TInvoiceRec = record
    Ident: RawUTF8;
    Article: TSQLArticle;
    Qty : Double;
    Amount: currency;
  end;
  TInvoiceRecs = array of TInvoiceRec;

I'm on Delphi7.

#52 mORMot 1 » Show DynArry with DrawGrid » 2014-05-29 15:45:08

tech
Replies: 9

Hi all,

I have the same Invoice class as in the documentation and I want to display the "Details: TInvoiceRecs" on a drawGrid, how can I do this ?

type
  TInvoiceRec = record
    Ident: RawUTF8;
    Amount: currency;
  end;
  TInvoiceRecs = array of TInvoiceRec;
  TSQLInvoice = class(TSQLRecord)
  protected
    fDetails: TInvoiceRecs;
    fTotal: Currency;
    procedure SetDetails(const Value: TInvoiceRecs);
  published
    property Details: TInvoiceRecs read fDetails write SetDetails;
    property Total: Currency read fTotal;
  end; 

#53 Re: mORMot 1 » SaveAsRawByteString problema » 2014-05-28 14:13:47

I think that you've missed

SaveAsRawByteString(imgDocument.Picture,doc,gptJPG,80,1500);

ContattoRecord := TSQLContacts.Create;
try
  ContattoRecord.Name = "something";
  ContattoRecord.Lastname= "something";
  ContattoRecord.Document := doc;   <--------------------------------------
  id := Database.Add(ContattoRecord, true);

  if id > 0 then
    begin
      Database.UpdateBlob(TSQLContacts, id, 'Document', doc)
    end;
finally
  ContattoRecord.Free;
end;

#54 Re: mORMot 1 » ReadStringFromStream returns empty string » 2014-05-26 14:53:33

Ok AB it works now with TRawByteStringStream thnx,

BTW, the compilation error persists although I restarted the IDE and tryed to compile "01 - In Memory ORM" sample.

#55 Re: mORMot 1 » ReadStringFromStream returns empty string » 2014-05-26 11:27:47

I forgot the MaxAllowedSize parameter then I put :

    Report.SaveToStream(msStream);
    msStream.seek(0,soBeginning);
    msStream.Read(L,4);
    ShowMessage(ReadStringFromStream(msStream, L));

and I got an Out of memory here

function ReadStringFromStream(S: TStream; MaxAllowedSize: integer): RawUTF8;
var L: integer;
begin
  result := '';
  L := 0;
  if (S.Read(L,4)<>4) or (L<=0) or (L>MaxAllowedSize) then
    exit;
  SetLength(Result,L);   <--------------------- out of memory L = 1702240364
  if S.Read(pointer(result)^,L)<>L then
    result := '';
end;

#56 Re: mORMot 1 » ReadStringFromStream returns empty string » 2014-05-26 08:55:23

Hi AB,

It doesn't work for me yikes When I've updated the source with the latest one, I got this compilation error in syncommons.pas at line 25231

[Erreur fatale] SynCommons.pas(25231): Erreur interne : C3950

I'm on D7 and win8

#57 Re: mORMot 1 » ReadStringFromStream returns empty string » 2014-05-26 07:00:45

Sorry but it doesn't work for me, I've already an empty string !!

#58 mORMot 1 » ReadStringFromStream returns empty string » 2014-05-25 21:24:19

tech
Replies: 17

Hi,

I've a TMemorystream containing a fastreport file (xml) that I want to save onto a blob field but this code doesn't work

  try
    Stream := TMemoryStream.Create;
    Stream.Position := 0;
    Report.SaveToStream(Stream);
    ShowMessage(ReadStringFromStream(Stream)); <--- Empty string although Stream.Size = 1828
  finally
    Stream.Free;
  end;

#59 Re: mORMot 1 » How to show joined table on the TSQLRibbonTabParameters » 2014-05-09 16:13:30

Hi AB,

I added two properties to TSQLRibbonTabParameters SQLWhere  and FieldAlign

unit mORMot;
....
  /// defines the settings for a Tab for User Interface generation
  // - used in mORMotToolBar.pas unit and TSQLModel.Create() overloaded method
  TSQLRibbonTabParameters = object
  public
    /// the Table associated to this Tab
    Table: TSQLRecordClass;
    /// the caption of the Tab, to be translated on the screen
    // - by default, Tab name is taken from TSQLRecord.Caption(nil) method
    // - but you can override this value by setting a pointer to a resourcestring
    CustomCaption: PResStringRec;
    /// the hint type of the Tab, to be translated on the screen
    // - by default, hint will replace all %s instance by the Tab name, as taken
    // from TSQLRecord.Caption(nil) method
    // - but you can override this value by setting a pointer to a resourcestring
    CustomHint: PResStringRec;
    /// SQL fields to be displayed on the data lists
    // 'ID,' is always added at the beginning
    Select: RawUTF8;
    /// SQL where to apply
    SQLWhere : RawUTF8;   <------------------------------
     /// Tab Group number (index starting at 0)
    Group: integer;
    /// displayed field length mean, one char per field (A=1,Z=26)
    // - put lowercase character in order to center the field data
    FieldWidth: RawUTF8; 
    /// displayed field align, one char par field (r=Right, l=Left, c=Center)
    FieldAlign: RawUTF8;   <------------------------------
....
unit mORMotToolBar;
......
constructor Create(aOwner: TComponent; aClient: TSQLRestClientURI;
      aClass: TSQLRecordClass; aGrid: TDrawGrid; aIDColumnHide: boolean;
      aPager: TSynPager; aImageList32,aImageList16: TImageList;
      aOnButtonClick: TSQLListerEvent; aOnValueText: TValueTextEvent;
      const aGridSelect: RawUTF8= '*'; const aGridSQLWhere: RawUTF8= '';  <---------------------------------------------
      aHideDisabledButtons: boolean=false;
      aHeaderCheckboxSelectsInsteadOfSort: Boolean=false); reintroduce; overload;
....
Constructor TSQLLister.Create(aOwner: TComponent; aClient: TSQLRestClientURI;
      aClass: TSQLRecordClass; aGrid: TDrawGrid; aIDColumnHide: boolean;
      aPager: TSynPager; aImageList32,aImageList16: TImageList;
      aOnButtonClick: TSQLListerEvent; aOnValueText: TValueTextEvent;
      const aGridSelect: RawUTF8= '*'; const aGridSQLWhere: RawUTF8= ''; <---------------------------------------------
      aHideDisabledButtons: boolean=false;
      aHeaderCheckboxSelectsInsteadOfSort: Boolean=false);
var T: TSQLTable;
begin
  if (aClient=nil) or (aGridSelect='') then
    T := nil else
    T := aClient.List([aClass],aGridSelect, aGridSQLWhere); <---------------------------------------------
  Create(aOwner,aClient,aClass,aGrid,aIDColumnHide,aPager,
    aImageList32,aImageList16,aOnButtonClick,aOnValueText,T,aHideDisabledButtons,
    aHeaderCheckboxSelectsInsteadOfSort);
end;

.................

constructor TSQLRibbonTab.Create(ToolBar: TSynPager; Body: TSynBodyPager;
  aImageList32,aImageList16: TImageList; var aPagesShortCuts: TFreeShortCut;
  const aTabParameters: TSQLRibbonTabParameters;
  Client: TSQLRestClientURI; aUserRights: TSQLFieldBits;
  aOnValueText: TValueTextEvent; SetAction: TSQLRibbonSetActionEvent;
  const ActionsTBCaptionCSV, ActionsHintCaption: string; ActionIsNotButton: pointer;
  aOnActionClick: TSQLListerEvent; ViewToolbarIndex: integer;
  aHideDisabledButtons, aHeaderCheckboxSelectsInsteadOfSort: boolean);
......
begin
......
  Lister := TSQLLister.Create(Page,Client,Table,List,not aTabParameters.ShowID,
    Toolbar,aImageList32,aImageList16,aOnActionClick,aOnValueText,
    'ID,'+aTabParameters.Select,aTabParameters.SQLWhere, <---------------------------------------------
     aHideDisabledButtons,aHeaderCheckboxSelectsInsteadOfSort);
......
  if TableToGrid<>nil then begin
    TableToGrid.SetFieldLengthMean(U,actMark in Act, aTabParameters.FieldAlign); <---------------------------------------------
......
end;
unit mORMotUI;
......
procedure SetFieldLengthMean(const Lengths: RawUTF8; aMarkAllowed: boolean; const Aligns: RawUTF8='');<---------------------------------------------
......
procedure TSQLTableToGrid.SetFieldLengthMean(const Lengths: RawUTF8; aMarkAllowed: boolean; const Aligns: RawUTF8='');
var L, i: integer;
    c: AnsiChar;
    Means: array of cardinal;
    a: AnsiChar;<---------------------------------------------
begin
  if self=nil then Exit;
  fMarkAllowed := aMarkAllowed;
  L := length(Lengths);
  if L=0 then begin
    SetLength(Means,Table.FieldCount);
    for i := 0 to Table.FieldCount-1 do
      Means[i] := 10; // some fixed width
  end else
  if Table.FieldCount=L then begin
    SetLength(Means,L);
    for i := 0 to L-1 do begin
      c := Lengths[i+1];
      if Aligns <> '' then                  <---------------------------------------------
      begin                                   <---------------------------------------------
        a := Aligns[i+1];                  <---------------------------------------------
        case a of                            <---------------------------------------------
          'l' :  Aligned[i] := alLeft;      <---------------------------------------------
          'r' :  Aligned[i] := alRight;    <---------------------------------------------
          'c' :  Aligned[i] := alCenter; <---------------------------------------------
        end;                                  <---------------------------------------------
      end                                     <---------------------------------------------
      else                                     <---------------------------------------------
      if c in ['a'..'z'] then begin
        Aligned[i] := alCenter;
        dec(c,32);
      end;
      Means[i] := ord(c)+(-ord('A')+1);
    end;
    Table.SetFieldLengthMean(Means);
  end;
  if aMarkAllowed then
    Table.FieldLengthMeanIncrease(0,2); // space for Marked[] checkbox e.g.
end;

But for the joined table fields I'm blocked here:

unit mORMot;
......
function TSQLRestClientURI.List(const Tables: array of TSQLRecordClass;
  const SQLSelect, SQLWhere: RawUTF8): TSQLTableJSON;
var Resp, SQL: RawUTF8;
    U: RawUTF8;
    InternalState: cardinal;
    props: TSQLModelRecordProperties; <---------------------------------------------
begin
  result := nil;
  if high(Tables)<0 then exit;
  // GET Collection
  props := Model.Props[Tables[0]]; <---------------------------------------------
  SQL := props.SQL.SelectAllJoined; <---------------------------------------------
  if SQL = '' then                          <---------------------------------------------
    SQL := Model.SQLFromSelectWhere(Tables,SQLSelect,SQLWhere); <-------- SQLSelect='Name,Created,Modified,KeyWords,SignatureTime,joinedTable.Field1'
  if high(Tables)=0 then begin
    // one Table -> use REST protocol (SQL as parameters)
    if not IsRowID(pointer(SQLSelect)) then
      // ID selected by default
      U := '?select='+UrlEncode(SQLSelect) else
      U := '';
    if SQLWhere<>'' then begin
      if U<>'' then
        U := U+'&where=' else
        U := U+'?where=';
      U := U+UrlEncode(SQLWhere);
    end;
    with URI(Model.URI[TSQLRecordClass(Tables[0])]+U,'GET',@Resp) do <--- I got 'no such column : JoinedTable.Field1' because the URI accept only one table
      if Lo<>HTML_SUCCESS then
        exit else
        InternalState := Hi;
    result := TSQLTableJSON.CreateFromTables([Tables[0]],SQL,Resp); // get data
  end else begin
    // multiple tables -> send SQL statement as HTTP body
    with URI(Model.Root,'GET',@Resp,nil,@SQL) do
      if Lo<>HTML_SUCCESS then
        exit else
        InternalState := Hi;
    result := TSQLTableJSON.CreateFromTables(Tables,SQL,Resp); // get data
  end;
  result.fInternalState := InternalState;
end;

thnx,

#60 Re: mORMot 1 » How to show joined table on the TSQLRibbonTabParameters » 2014-05-07 10:59:37

Is there a way to detect the existance of a joined field in the TSQLRibbonTabParameters.Select property and then embed automaticaly the whole content ?
Why there's not a TSQLRibbonTabParameters.SQLWhere property to add a filter if needed ?

Thx,

#61 mORMot 1 » How to show joined table on the TSQLRibbonTabParameters » 2014-05-07 10:14:29

tech
Replies: 4

Hi,

I use TSQLRibbonTabParameters like in the MainDemo and I want to show some fields of the joined table instead of the ID.
I suppose that TSQLMemo has a property pointing joinedTable, is it possibile to do that :

(Table: TSQLMemo;
     Select: 'Name,Created,Modified,KeyWords,SignatureTime,joinedTable.Field1,joinedTable.Field2'; Group: GROUP_CLEAR; FieldWidth: 'IddIdII'; Actions: DEF_ACTIONS)

Thx,

#62 Re: mORMot 1 » MSSql connection problem with TOleDBMSSQL2008ConnectionProperties » 2014-03-26 11:32:22

The "globalClient" is an instance of a class derived from TSQLHttpClient and  I run the code on the client like on the MainDemo.

#64 Re: mORMot 1 » MSSql connection problem with TOleDBMSSQL2008ConnectionProperties » 2014-03-25 16:05:20

I switched to ODBC as you said, but I get the following error when I check the existence of a record and I try to create it if it does not exist:

'[HY000] [Microsoft][SQL Server Native Client 10.0]La connexion est occupée avec les résultats d'une autre commande (0)'

This is my code

var jmouv : TSQLmsJMOUV;
begin
  Result := True;
  try
    jmouv := TSQLmsJMOUV.CreateAndFillPrepare(globalClient, 'JO_NUM= ? AND JM_date = ?', [JO_NUM, DateToSQL(JM_date)]);
    jmouv.FillOne;
    if jmouv.JO_Num = '' then
    begin
      jmouv.fJO_Num := JO_NUM;
      jmouv.fJM_Date := JM_date;
      jmouv.fJM_Cloture := 0;
      jmouv.fJM_Impression := 0;
      globalClient.Add(jmouv, True);   <==================== The error 
    end;
  finally
    jmouv.Free;
  end;
end;

#65 Re: mORMot 1 » MSSql connection problem with TOleDBMSSQL2008ConnectionProperties » 2014-03-22 11:29:59

Hi,

I've debug remotly the app on the client machine and the exception occurs here :

procedure TOleDBConnection.Connect;
var DataInitialize : IDataInitialize;
    unknown: IUnknown;
    Log: ISynLog;
begin
  ....
    OleCheck(DataInitialize.GetDataSource(nil,CLSCTX_INPROC_SERVER,
      pointer(OleDBProperties.ConnectionString),
      IID_IDBInitialize,IUnknown(fDBInitialize)));  <======================= 1st Exception
      DataInitialize := nil;
      // open the connection to the DB
      OleDBCheck(fDBInitialize.Initialize);        <======================= 2st Exception
  ....
end;

After that I discovered that the sql native client for mssql 2008 was not installed on the client machine. I've installed the SNCLI10 and I got an other exception, this is the log file :

C:\Projets\bala\Comm2 1.0.0.0 (2014-03-22 11:14:12)
Host=OMNICLIENT User=bala CPU=1*0-15-1025 OS=4.2=5.2.3790 Wow64=0 Freq=3579545
Environment variables=ALLUSERSPROFILE=C:\Documents and Settings\All Users	APPDATA=C:\Documents and Settings\bala\Application Data	CLIENTNAME=ADELON	ClusterLog=C:\WINDOWS\Cluster\cluster.log	CommonProgramFiles=C:\Program Files\Fichiers communs	COMPUTERNAME=OMNICLIENT	ComSpec=C:\WINDOWS\system32\cmd.exe	FP_NO_HOST_CHECK=NO	HOMEDRIVE=C:	HOMEPATH=\Documents and Settings\bala	LOGONSERVER=\\OMNICLIENT	MOZ_PLUGIN_PATH=C:\Program Files\Foxit Software\Foxit Reader\plugins\	NUMBER_OF_PROCESSORS=1	OS=Windows_NT	Path=C:\PROGRA~1\Borland\REMOTE~1\7.0\Bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\	PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH	PROCESSOR_ARCHITECTURE=x86	PROCESSOR_IDENTIFIER=x86 Family 15 Model 4 Stepping 1, GenuineIntel	PROCESSOR_LEVEL=15	PROCESSOR_REVISION=0401	ProgramFiles=C:\Program Files	SESSIONNAME=RDP-Tcp#3	SystemDrive=C:	SystemRoot=C:\WINDOWS	TEMP=C:\DOCUME~1\bala\LOCALS~1\Temp\1	TMP=C:\DOCUME~1\bala\LOCALS~1\Temp\1	USERDOMAIN=OMNICLIENT	USERNAME=bala	USERPROFILE=C:\Documents and Settings\bala	windir=C:\WINDOWS
TSQLLog 1.18 2014-03-22T11:22:52

20140322 11225240  +    000DEE6C SynSQLite3.TSQLDatabase.DBOpen (3438) 
20140322 11225240  +    	TSQLDatabase(01007360).000DE67E SynSQLite3.TSQLDatabase.Execute (3077) 
20140322 11225240 SQL   		PRAGMA cache_size=10000
20140322 11225240  -    	00.001.948
20140322 11225240  -    00.003.580
20140322 11225240  +    TSQLDatabase(01007360).000DE778 SynSQLite3.TSQLDatabase.Execute (3210) 
20140322 11225240 SQL   	SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%';
20140322 11225240  -    00.000.167
20140322 11225240 debug TSQLDatabase(01007360) TableNames=["Params"]
20140322 11225240 cache TSQLDatabase(01007360) not in cache
20140322 11225240 SQL   TSQLRestServerDB(00F0B5A0) SELECT ID,Societe,CG_RegD,CG_RegC,myServer,myBDD,myUser,myPwd,myLibmySQL,msServer,msBDD,msUser,msPwd FROM Params; is no prepared statement
20140322 11225240 res   TSQLDatabase(01007360) {"fieldCount":13,"values":["ID","Societe","CG_RegD","CG_RegC","myServer","myBDD","myUser","myPwd","myLibmySQL","msServer","msBDD","msUser","msPwd"],"rowCount":0} 
20140322 11230615  +    TOleDBConnection(00FE4108).00249576 SynOleDB.TOleDBConnection.Create (1975) 
20140322 11230615  -    00.000.006
20140322 11230615  +    TOleDBConnection(00FE4108).002492E4 SynOleDB.TOleDBConnection.Connect (1938) 
20140322 11233024 ERROR 	"EOleDBException(01015C70)":"Erreur non spécifiée -   (line 0): Fournisseur de canaux nommés : Impossible d'ouvrir une connexion à SQL Server [1326]. \r\n" stack trace API 00249BC7 SynOleDB.TOleDBConnection.OleDBCheck (2079) 002493C5 SynOleDB.TOleDBConnection.Connect (1954) 002959F8 Options.TOptionForm.btnmsSQLClick (170) 0006B656 Controls.TControl.Click 0006E408 Controls.TWinControl.WndProc 0006E540 Controls.DoControlMsg 0006E408 Controls.TWinControl.WndProc 0002837A Classes.StdWndProc 
20140322 11233024 EXC   	EOleDBException ("Erreur non spécifiée -   (line 0): Fournisseur de canaux nommés : Impossible d'ouvrir une connexion à SQL Server [1326]. \r\n") at 00249AAF SynOleDB.EnhancedTest (2073)  stack trace API 000A6DC8 SynCommons.SynRtlUnwind (32354) 000039F0 System.@HandleOnException 
20140322 11233024 ERROR 	"EOleDBException(01015C70)":"Erreur non spécifiée -   (line 0): Fournisseur de canaux nommés : Impossible d'ouvrir une connexion à SQL Server [1326]. \r\n" stack trace API 002959F8 Options.TOptionForm.btnmsSQLClick (170) 0006B656 Controls.TControl.Click 0006E408 Controls.TWinControl.WndProc 0006E540 Controls.DoControlMsg 0006E408 Controls.TWinControl.WndProc 0002837A Classes.StdWndProc 0006E4EC Controls.TWinControl.DefaultHandler 
20140322 11233024 EXC   	EOleDBException ("Erreur non spécifiée -   (line 0): Fournisseur de canaux nommés : Impossible d'ouvrir une connexion à SQL Server [1326]. \r\n") at 00249AAF SynOleDB.EnhancedTest (2073)  stack trace API 000A6DC8 SynCommons.SynRtlUnwind (32354) 000039F0 System.@HandleOnException 

I forgot that mssql server used named pipe, TCP/IP and shared memory

#66 Re: mORMot 1 » MSSql connection problem with TOleDBMSSQL2008ConnectionProperties » 2014-03-21 10:00:45

This is the log file after adding .map file to the exe :

C:\Projets\bala\Comm2.exe 1.0.0.0 (2014-03-21 09:42:14)
Host=OMNICLIENT User=bala CPU=1*0-15-1025 OS=4.2=5.2.3790 Wow64=0 Freq=3579545
Environment variables=ALLUSERSPROFILE=C:\Documents and Settings\All Users	APPDATA=C:\Documents and Settings\bala\Application Data	CLIENTNAME=ADELON	ClusterLog=C:\WINDOWS\Cluster\cluster.log	CommonProgramFiles=C:\Program Files\Fichiers communs	COMPUTERNAME=OMNICLIENT	ComSpec=C:\WINDOWS\system32\cmd.exe	FP_NO_HOST_CHECK=NO	HOMEDRIVE=C:	HOMEPATH=\Documents and Settings\bala	LOGONSERVER=\\OMNICLIENT	MOZ_PLUGIN_PATH=C:\Program Files\Foxit Software\Foxit Reader\plugins\	NUMBER_OF_PROCESSORS=1	OS=Windows_NT	Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem	PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH	PROCESSOR_ARCHITECTURE=x86	PROCESSOR_IDENTIFIER=x86 Family 15 Model 4 Stepping 1, GenuineIntel	PROCESSOR_LEVEL=15	PROCESSOR_REVISION=0401	ProgramFiles=C:\Program Files	SESSIONNAME=RDP-Tcp#3	SystemDrive=C:	SystemRoot=C:\WINDOWS	TEMP=C:\DOCUME~1\bala\LOCALS~1\Temp\1	TMP=C:\DOCUME~1\bala\LOCALS~1\Temp\1	USERDOMAIN=OMNICLIENT	USERNAME=bala	USERPROFILE=C:\Documents and Settings\bala	windir=C:\WINDOWS
TSQLLog 1.18 2014-03-21T09:51:36

20140321 09513636  +    000DEE6C SynSQLite3.TSQLDatabase.DBOpen (3438) 
20140321 09513636  +    	TSQLDatabase(01007360).000DE67E SynSQLite3.TSQLDatabase.Execute (3077) 
20140321 09513636 SQL   		PRAGMA cache_size=10000
20140321 09513636  -    	00.000.512
20140321 09513636  -    00.000.908
20140321 09513636  +    TSQLDatabase(01007360).000DE778 SynSQLite3.TSQLDatabase.Execute (3210) 
20140321 09513636 SQL   	SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%';
20140321 09513636  -    00.000.164
20140321 09513636 debug TSQLDatabase(01007360) TableNames=["Params"]
20140321 09513636 cache TSQLDatabase(01007360) not in cache
20140321 09513636 SQL   TSQLRestServerDB(00F0B5A0) SELECT ID,Societe,CG_RegD,CG_RegC,myServer,myBDD,myUser,myPwd,myLibmySQL,msServer,msBDD,msUser,msPwd FROM Params; is no prepared statement
20140321 09513636 res   TSQLDatabase(01007360) {"fieldCount":13,"values":["ID","Societe","CG_RegD","CG_RegC","myServer","myBDD","myUser","myPwd","myLibmySQL","msServer","msBDD","msUser","msPwd"],"rowCount":0} 
20140321 09515145  +    TOleDBConnection(00FE4108).00249576 SynOleDB.TOleDBConnection.Create (1975) 
20140321 09515145  -    00.000.006
20140321 09515145  +    TOleDBConnection(00FE4108).002492E4 SynOleDB.TOleDBConnection.Connect (1938) 
20140321 09515158 EXC   	EOleSysError 80040154 ("Classe non enregistrée") at 001649E9 ComObj.OleError  stack trace API 000AE330 SynCommons.SynRtlUnwind (32354) 000039F0 System.@HandleOnException 
20140321 09515158 ERROR 	"EOleSysError(01C1C780)":"Classe non enregistrée" stack trace API 002959F8 Options.TOptionForm.btnmsSQLClick (170) 0006B656 Controls.TControl.Click 0006E408 Controls.TWinControl.WndProc 0006E540 Controls.DoControlMsg 0006E408 Controls.TWinControl.WndProc 0002837A Classes.StdWndProc 0006E4EC Controls.TWinControl.DefaultHandler 
20140321 09515158 EXC   	EOleSysError 80040154 ("Classe non enregistrée") at 001649E9 ComObj.OleError  stack trace API 000AE330 SynCommons.SynRtlUnwind (32354) 000039F0 System.@HandleOnException 

#67 Re: mORMot 1 » MSSql connection problem with TOleDBMSSQL2008ConnectionProperties » 2014-03-20 17:39:37

Yes I've updated to the latest unstable version but the problem persists.

Here's the log file :

C:\Projets\bala\Comm2.exe 1.0.0.0 (2014-03-20 17:26:14)
Host=OMNICLIENT User=bala CPU=1*0-15-1025 OS=4.2=5.2.3790 Wow64=0 Freq=3579545
Environment variables=ALLUSERSPROFILE=C:\Documents and Settings\All Users	APPDATA=C:\Documents and Settings\bala\Application Data	CLIENTNAME=ADELON	ClusterLog=C:\WINDOWS\Cluster\cluster.log	CommonProgramFiles=C:\Program Files\Fichiers communs	COMPUTERNAME=OMNICLIENT	ComSpec=C:\WINDOWS\system32\cmd.exe	FP_NO_HOST_CHECK=NO	HOMEDRIVE=C:	HOMEPATH=\Documents and Settings\bala	LOGONSERVER=\\OMNICLIENT	MOZ_PLUGIN_PATH=C:\Program Files\Foxit Software\Foxit Reader\plugins\	NUMBER_OF_PROCESSORS=1	OS=Windows_NT	Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem	PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH	PROCESSOR_ARCHITECTURE=x86	PROCESSOR_IDENTIFIER=x86 Family 15 Model 4 Stepping 1, GenuineIntel	PROCESSOR_LEVEL=15	PROCESSOR_REVISION=0401	ProgramFiles=C:\Program Files	SESSIONNAME=RDP-Tcp#1	SystemDrive=C:	SystemRoot=C:\WINDOWS	TEMP=C:\DOCUME~1\bala\LOCALS~1\Temp\1	TMP=C:\DOCUME~1\bala\LOCALS~1\Temp\1	USERDOMAIN=OMNICLIENT	USERNAME=bala	USERPROFILE=C:\Documents and Settings\bala	windir=C:\WINDOWS
TSQLLog 1.18 2014-03-20T17:29:17

20140320 17291716  +    004DFE6C 
20140320 17291716  +    	TSQLDatabase(01007360).004DF67E 
20140320 17291716 SQL   		PRAGMA cache_size=10000
20140320 17291716  -    	00.006.187
20140320 17291716  -    00.007.715
20140320 17291716  +    TSQLDatabase(01007360).004DF778 
20140320 17291716 SQL   	SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%';
20140320 17291716  -    00.000.164
20140320 17291716 debug TSQLDatabase(01007360) TableNames=["Params"]
20140320 17291716 cache TSQLDatabase(01007360) not in cache
20140320 17291716 SQL   TSQLRestServerDB(00F0B5A0) SELECT ID,Societe,CG_RegD,CG_RegC,myServer,myBDD,myUser,myPwd,myLibmySQL,msServer,msBDD,msUser,msPwd FROM Params; is no prepared statement
20140320 17291716 res   TSQLDatabase(01007360) {"fieldCount":13,"values":["ID","Societe","CG_RegD","CG_RegC","myServer","myBDD","myUser","myPwd","myLibmySQL","msServer","msBDD","msUser","msPwd"],"rowCount":0} 
20140320 17300157  +    TOleDBConnection(00FE4038).0064A576 
20140320 17300157  -    00.000.006
20140320 17300157  +    TOleDBConnection(00FE4038).0064A2E4 
20140320 17300207 EXC   	EOleSysError 80040154 ("Classe non enregistrée") at 005659E9  stack trace API 004AF330 004049F0 
20140320 17300207 ERROR 	"EOleSysError(01C49B30)":"Classe non enregistrée" stack trace API 004B0E7E 004B0266 006969F8 0046C656 0046F408 0046F540 0046F408 0042937A 77F4B6E3 77F4B874 77F4C2D3 77F4C337 77E489F7 77E48AD9 77E4ADDE 77F4B6E3 77F4B874 77F4BFCE 77F60463 0046F4EC 
20140320 17300207 EXC   	EOleSysError 80040154 ("Classe non enregistrée") at 005659E9  stack trace API 004AF330 004049F0 

#68 Re: mORMot 1 » MSSql connection problem with TOleDBMSSQL2008ConnectionProperties » 2014-03-20 15:39:47

The server is windows 2008 and the client is windows7.
The version of oleDb dll is 6.1.96.
The class name that I got is EOleSysError.

For the n-Tier architecture I will switch to it later, it is juste because my app is not yet OK and I must install it for testing.

Here's my code for testing connection :

procedure TOptionForm.btnmsSQLClick(Sender: TObject);
var PropsMS : TOleDBMSSQL2008ConnectionProperties;
    Conn: TSQLDBConnection;
begin
  try
    try
      PropsMS := TOleDBMSSQL2008ConnectionProperties.Create(edtmsServer.Text, edtmsBdd.Text, edtmsUser.Text, edtmsPwd.Text);
      Conn := PropsMS.NewConnection;
      Conn.Connect;
      ShowMessage('Connexion OK');
    Except
      on E : Exception do
      ShowMessage('Connexion impossible au '+ edtmsServer.Text +'\'+ edtmsBdd.Text + #10#13+
                  'Exception class = '+E.ClassName + #10#13+
                  'Exception message = '+E.Message);
    end;
  finally
    Conn.free;
    PropsMS.Free;
  end;
end;

#70 mORMot 1 » MSSql connection problem with TOleDBMSSQL2008ConnectionProperties » 2014-03-20 12:11:24

tech
Replies: 17

Hi,

If I launch my app on the server it makes connection fine, but if I launch it on a client machine it doesn't.
What I don't understand is that I've another app making connection fine via ADO component and OLEDB !!

What I'm missing here ?

N.B: The client and the server are on the same domaine.

I got an Unregistred Class exception.

#72 Re: mORMot 1 » forcing 'ID' by another field name on virtual table » 2014-03-20 09:56:49

I use the MapField() right.On the external mysql table I've ID field and I've mapped it into myID field of the internal table.

#73 Re: mORMot 1 » forcing 'ID' by another field name on virtual table » 2014-03-18 10:05:48

That is what I do :

aProps := TSQLDBZeosConnectionProperties.Create(TSQLDBZeosConnectionProperties.URI(dMySQL, myServer, 'libmysql.dll', False),
                myDB, myUser, myPwd);
VirtualTableExternalRegister(globalModel, TSQLmyTable, aProps, 'TableExternal');
globalModel.Props[TSQLmyTable].ExternalDB.MapField('myID', 'ID');

All this works fine and I retreive the varchar250 key, but I got error when I try to update one record on the external table via varchar250 key.

globalClient.EngineExecute('UPDATE myTABLE SET FIELD1 = VAL1 WHERE ID='+ Varchar250key);

#74 mORMot 1 » Reset ID after 'DELETE FROM TABLE' » 2014-03-17 18:48:53

tech
Replies: 2

Hi,
Is it possible to reset the ID after this ?

globalClient.EngineExecute('delete from table');

The table is temporary and I want to start new IDs after a delete.

#75 Re: mORMot 1 » forcing 'ID' by another field name on virtual table » 2014-03-17 18:39:22

I've tested the mapping feature and it works fine like that

globalModel.Props[TSQLmyTable].ExternalDB.MapField('mySQLID', 'ID');

But I get the 'no such column:ID' error when I try this update sad :

globalClient.EngineExecute('UPDATE myTABLE SET FIELD1 = VAL1 WHERE ID='+ Varchar250key);

#76 Re: mORMot 1 » TSQLTableToGrid Fields width and Align » 2014-03-17 18:12:04

Well, I begin to understand the philosophy of fieldWidth.
We must have the same number of letters that fields if we want it to work.
The width of the field is calculated according to the ord value of the letter, and the alignment is Left if uppercase and center if lowercase, but nothing for the right one.
I think it is better to have another parameter FieldAlign: 'lrc' with l: Left, r: Rigth and c: Center.
In the meantime I replaced the alCenter by alRight in SetFieldLengthMean because I do not need it.
What do you think AB ?

I solved the precision display by adding another RawUTF8 field that contains the correct string to display.

Thnx,

#77 mORMot 1 » TSQLTableToGrid Fields width and Align » 2014-03-16 20:30:17

tech
Replies: 1

Hi,

I want to set the column widths and I can not understand how does this syntax:

fieldWidth : 'IddId'

I also want to align double and currency fields to the right with an accuracy of 2.

Thnx,

#78 Re: mORMot 1 » can't localize and i18n my app » 2014-03-14 18:02:23

After i18n i got a stackoverflow when :

StrToFloat(table.GetS(X, 1))

The field 1 on the table is a double.
Which conversion function we must use without i18n ?

#79 Re: mORMot 1 » can't localize and i18n my app » 2014-03-14 16:53:11

Great I've convert the file into ANSI and it works fine now.

There's somethings that doesn't work. The resourcestrings was not extracted into .messages !

#80 Re: mORMot 1 » can't localize and i18n my app » 2014-03-14 16:19:27

Hi AB,

I used the USEFORMCREATEHOOK and it works but there is one issue with french è, é, à ....
e.i: Société is written like that: http://105.157.31.10:8888/mormot.png

#81 mORMot 1 » can't localize and i18n my app » 2014-03-14 10:48:33

tech
Replies: 7

Hi,

First I've extracted all ressources and the .messages file was created then I've created a new file myapp.FR with some strings translation and set the language to FR

procedure TMainForm.FormShow(Sender: TObject);
begin
{$ifdef EXTRACTALLRESOURCES}
  ExtractAllResources(
    // first, all enumerations to be translated
    [TypeInfo(TFileEvent),TypeInfo(TFileAction){,TypeInfo(TPreviewAction)}],
    // then some class instances (including the TSQLModel will handle all TSQLRecord)
    [globalClient.Model],
    // some custom classes or captions
    [],[]);
  Close;
{$else}
  i18nLanguageToRegistry(lngFrench);
{$endif}

  Ribbon.ToolBar.ActivePageIndex := 0;
  i18nDateText := Iso2S;
end;

When I launch the project, the UI still not localized neither translated into french !

#82 Re: mORMot 1 » Suggestion for Authentication » 2014-03-14 10:37:28

Hi,

this is an example for connecting to MSSQL via OLE and virtual table :

uses SynOleDB, ....;
...
var aPropsMS : TOleDBMSSQL2008ConnectionProperties;
   Model : TSQLModel;
...
aPropsMS := TOleDBMSSQL2008ConnectionProperties.Create(server, database, user, pwd);
Model := TSQLModel.Create([TSQLCLASS]);

VirtualTableExternalRegister(Model, TSQLCLASS, aPropsMS, 'MS_TABLE_NAME');

CreateMissingTables(0);

You can explore the code of 15 - External DB performance.

Ooops I did not saw the post of AB.

#83 Re: mORMot 1 » EAccessViolation in module ntdll.dll at 0001E12C » 2014-03-14 09:44:49

I can send you the whole project but by private email if you wish.

#84 Re: mORMot 1 » Retrieve the drawGrid associated to a TSQLRecord » 2014-03-14 09:39:38

I've marked the incoherent records then modify the NewDrawCellBackground to color marked when MARKEDROWSCOLORED is defined

{$define MARKEDROWSCOLORED}
// if defined, all Marked[] rows are highligted with a different background color

procedure NewDrawCellBackground(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState;
  {$ifdef USETMSPACK} TabAppearance: TTabAppearance;{$endif} Marked: boolean);
var Grid: TDrawGrid absolute Sender;
begin
  if not Sender.InheritsFrom(TDrawGrid) then
    exit;
{$ifdef USETMSPACK}
  if TabAppearance<>nil then
  with TabAppearance, Grid.Canvas do begin
    Font := Grid.Font;
    if (gdFixed in State) then begin
      Brush.Color := BackGround.Color;
      Font.Color := TextColor;
      Pen.Color := ShadowColor;
      inc(Rect.Bottom,1);
      MoveTo(Rect.Right,Rect.Top);
      LineTo(Rect.Right,Rect.Bottom);
    end else
    if Marked then
      if (gdSelected in State) then begin
        Brush.Color := HighLightColorSelected;
        Font.Color := TextColorHot;
      end else
        Brush.Color := HighLightColor else
      if (gdSelected in State) then begin
        Brush.Color := ColorHot;
        Font.Color := TextColorHot;
      end else
        Brush.Color := ColorTo;
{$else}
  with Grid.Canvas do begin
    Font := Grid.Font;
    if gdFixed in State then begin
      Font.Color := clCaptionText;
      Brush.Color := clGradientInactiveCaption;
      Pen.Color := clGrayText;
      inc(Rect.Bottom,1);
      MoveTo(Rect.Right,Rect.Top);
      LineTo(Rect.Right,Rect.Bottom);
    end else
  {$IFDEF MARKEDROWSCOLORED}
    if Marked then
    begin
        Brush.Color := clLime;
        Font.Color := clWindowText;
    end
    else
    if (gdSelected in State) then begin
      Font.Color := clHighlightText;
      Brush.Color := clHighlight;
    end else begin
      Font.Color := clWindowText;
      Brush.Color := clWindow;
    end;
  {$else}
    if (gdSelected in State) then begin
      Font.Color := clHighlightText;
      Brush.Color := clHighlight;
    end else begin
      Font.Color := clWindowText;
      Brush.Color := clWindow;
    end;
  {$ENDIF}
{$endif}
    FillRect(Rect);
  end;
end;

Is it possible to have a global clMarked variable to be able to change it ?

#85 Re: mORMot 1 » EAccessViolation in module ntdll.dll at 0001E12C » 2014-03-14 09:13:57

Hi ab,

I just use FastMM4 in full debugg mode and EA has vanished without any memory leak !?

There are somethings wrong

#86 mORMot 1 » EAccessViolation in module ntdll.dll at 0001E12C » 2014-03-13 18:51:28

tech
Replies: 4

Hi all,

I got  this AV when freeing my server.

---------------------------
Application Error
---------------------------
Exception EAccessViolation in module ntdll.dll at 0001E12C.

Access violation at address 76F5E12C in module 'ntdll.dll'. Write of address 00000014.

---------------------------
OK   
---------------------------

The AV occurs exactly here :

destructor THttpApiServer.Destroy;
var i: integer;
begin
  if (fClones<>nil) and (Http.Module<>0) then begin  // fClones=nil for clone threads
    if fReqQueue<>0 then begin
      if Http.Version.MajorVersion>1 then begin
       if fUrlGroupID<>0 then begin
         Http.RemoveUrlFromUrlGroup(fUrlGroupID,nil,HTTP_URL_FLAG_REMOVE_ALL);
         Http.CloseUrlGroup(fUrlGroupID);
       end;
       CloseHandle(FReqQueue); 
       if fServerSessionID<>0 then
         Http.CloseServerSession(fServerSessionID);
      end else begin
        for i := 0 to high(fRegisteredUnicodeUrl) do
          Http.RemoveUrl(fReqQueue,pointer(fRegisteredUnicodeUrl[i]));
        CloseHandle(fReqQueue); // will break all THttpApiServer.Execute
      end;
      fReqQueue := 0;
      Http.Terminate(HTTP_INITIALIZE_SERVER);
    end;
    FreeAndNil(fClones);
  end;
  inherited Destroy;     <=================================== AV here
end;

The server is created here :

  Server := TSQLHttpServer.Create(SERVER_HTTP_PORT,self,'+',useHttpApiRegisteringURI);

and freed on the destroy :

FreeAndNil(Server);

All that like the maindemo of synFile.

I don't know what I'm doing wrong here.

#87 Re: mORMot 1 » forcing 'ID' by another field name on virtual table » 2014-03-13 17:25:30

In this case I'll use

globalClient.EngineExecute('UPDATE TABLE SET FIELD1 = VAL1 WHERE ID='+ Varchar250key)

thnx,

#88 Re: mORMot 1 » forcing 'ID' by another field name on virtual table » 2014-03-13 15:14:22

Great work Arnaud,

I'll test the mapping functionnality later.
I think that the easy way is to map the Varchar250 key into a RawUTF8 field (<> SQLite ID) and then specify it for the update/delete operations.

Merci beaucoup

#89 Re: mORMot 1 » forcing 'ID' by another field name on virtual table » 2014-03-13 09:41:11

I know but I can't modify the table structure. How can I get around this problem ?
My idea is to have a computed class property on delphi that copy the content of the mySQL ID for using it later.
Is there a way to have this?

Thnx,

#90 Re: mORMot 1 » forcing 'ID' by another field name on virtual table » 2014-03-13 07:08:15

Hi Arnaud,

I have the same problem with a mySql table that have 'ID' like this `id` varchar(250) NOT NULL.
when I get the records, the ID only takes integers from the start until it finds an alpha char of the mySQL ID field.
Example :

mySQL_ID = 1213E30377
SQLite_ID = 1213

How I can retrieve the entire primary key in order to change the record?

Thnx,

#92 Re: mORMot 1 » Retrieve the drawGrid associated to a TSQLRecord » 2014-03-11 20:17:37

I found TSQLRibbonTab.TableToGrid.DrawGrid and I'll use the mark option to draw incoherent records with red color.

Thanks,

#93 Re: mORMot 1 » Exception with FreeAndNil(TOleDBMSSQL2008ConnectionProperties) » 2014-03-11 17:12:38

I've emplemented the Server.HttpServer.OnHttpThreadTerminate notification to call this as indicated :

aPropsMS.EndCurrentThread;

but I got a serious AV
---------------------------
Application Error
---------------------------
Exception EAccessViolation in module project1.exe at 000043B8.

Access violation at address 004043B8 in module 'project1.exe'. Read of address 49776F2E.

---------------------------
OK   
---------------------------

I confess that I have trouble understanding how mORMot works.

Thnx,

#94 mORMot 1 » Retrieve the drawGrid associated to a TSQLRecord » 2014-03-11 15:24:39

tech
Replies: 2

Hi,

I'm creating the UI at run-time with the same code on the main demo with TSQLRibbon and I want to retrieve the draw grid associated to a TSQLRecord sub-class to have the possibility to draw some incoherent records with red color.
What I need is exactly the opposite of this function :

class function From(Grid: TDrawGrid): TSQLTableToGrid;

How can'I do that ?

Thanks,

#95 Re: mORMot 1 » Exception with FreeAndNil(TOleDBMSSQL2008ConnectionProperties) » 2014-03-11 09:44:29

The server is created/freed on the main form and the TOleDBMSSQL is created/freed on the server.
I think they are on the same thread.

#96 Re: mORMot 1 » Exception with FreeAndNil(TOleDBMSSQL2008ConnectionProperties) » 2014-03-10 12:29:34

aPropsMS := TOleDBMSSQL2008ConnectionProperties.Create('127.0.0.1', 'MSDB', 'sa', '');

and

FreeAndNil(aPropsMS);

All on the same unit.

the create is on the server.create and the freeAndNil on the Server.Destroy.
I don't use the interface-based services.

#97 mORMot 1 » Exception with FreeAndNil(TOleDBMSSQL2008ConnectionProperties) » 2014-03-10 12:17:24

tech
Replies: 8

Hi,

I got this exception when I try to freeing a TOleDBMSSQL2008ConnectionProperties :

'You should call TOleDBConnection.Free from the same thread which called its Create: i.e. call MyProps.EndCurrentThread from an THttpServerGeneric.OnHttpThreadTerminate event - see ticket 213544b2f5 

I saw the ticket but I don't understand what's wrong.

Thnx.

#99 Re: mORMot 1 » forcing 'ID' by another field name on virtual table » 2014-03-10 09:41:41

Ok, I'll add the ID to the virtual table and waiting for the ID field mapping feature.

thnx

#100 mORMot 1 » forcing 'ID' by another field name on virtual table » 2014-03-09 16:44:33

tech
Replies: 17

Hi,

I've mapped an existing mssql table that have primary key field 'NUM'. I want to force mORMot to use this field as its internal 'ID' because I can't create 'ID' field and want to continue incremental of 'NUM'.
Is this possible or not?

Thx.

Board footer

Powered by FluxBB