You are not logged in.
Pages: 1
@AB: Yes, I understood and fixed in the Client side and Model class. But how can I use only SynCrossPlatform* units in the mORMot Server side program?
It says Error on these lines when trying to compile mORmot Server. If I try to remove any of the Uses classes in the code below, then the error increases.
FYI, I am using MSSQL as a backend database.
Uses
SynLog, mORMot, mORMotSQLite3, SynSQLite3Static, mORMotDB, mORMotHttpServer, SynDB, SynDBODBC, mORMotWrappers, SynOleDB, SynCrossPlatformREST, RESTModel;
VirtualTableExternalRegister(aModel, TWareHouses, aProps); // my aModel class uses only SynCrossPlatform* units
try
aRestServer := TSQLRestServerDB.Create(aModel,':memory:',false);
aRestServer.AcquireExecutionMode[execORMGet] := amBackgroundORMSharedThread;
aRestServer.AcquireExecutionMode[execORMWrite] := amBackgroundORMSharedThread;
aRestServer.CreateMissingTables;
AddToServerWrapperMethod(aRestServer, ['..\..\..\CrossPlatform\templates','..\..\..\..\CrossPlatform\templates']);
aHttpServer := TSQLHttpServer.Create(SERVER_PORT,[aRestServer],'+',useHttpApiRegisteringURI);
try
aHttpServer.AccessControlAllowOrigin := '*';
writeln('Background server is running.'#10);
write('Press [Enter] to close the server.');
readln;
finally
aHttpServer.Free;
end;
finally
aRestServer.Free;
end;
I know that I am not using appropriate methods or classes in this mORMot server side, but I don't know what are they?
Kindly help me to fix this. Any available example for the Server side program for iOS/mobile applications?
Thanks in advance.
I have updated the fix now. But again, it's shows an Error: [DCC Fatal Error] SynCommons.pas(675): F1026 File not found: 'Contnrs.dcu'
Still, it hasn't solved. Any other suggestions please.
Btw, Thanks AB and Wim314 .
Thanks, but another Error popped up: File not found: 'Windows.dcu'
This error is shown under 'SynCrossPlatformSpecific' class.
Now I have removed mORMotHttpClient and using only SynCrossPlatformREST.
Any suggestions?
Hi AB!
I have already used these 2 units under my Uses section: SynCrossPlatformREST, SynCrossPlatformSpecific
FYI: These are my units in the Uses section of Client side other than standard Firemonkey units:
SynCommons,
mORMot,
SynCrossPlatformREST, SynCrossPlatformSpecific,
mORMotHttpClient, // HTTP client to a mORMot RESTful server
RESTModel; // data model unit, shared between server and client
Hi,
I am working with the iOS application. I am using latest mORMotNightlyBuild version.
On the client side when I am trying to compile through an activated iOS Simulator, I got an error- File not found:'Contnrs.dcu'.
And also, do we have any example for iOS application using mORMot client and server?
Could anyone help me regarding this issue?
Thanks in advance.
Thanks ab. I will look into it.
I mean, at the runtime if I need to fetch data from a different table for different purpose.
I didn't mean JOIN, anyhow I need to use JOIN function for later purposes. Thanks for your references, I will also look into those links.
Example Server side source code:
aModel := fetchModel; // TSQL Record Class for fetching data from 'Row1' table.
VirtualTableExternalRegister(aModel, TRow, aProps, 'Row1');
aModel.Props[TRow].ExternalDB.MapField('ID','IDNo');
try
aRestServer := TSQLRestServerDB.Create(aModel,':memory:',false);
In the above code, I am using a 'fetchModel' TSQLRecord Class for fetching data from a 'Row1' table. If I need to use another TSQLRecord Class like 'createModel' from a 'Package1' table for different purpose, what I need to do?
Kindly let me know, if I am not clear with my question.
Thanks in advance.
Hi,
I am working on a client server application. I have a REST Model which has more than one TSQL Record class for accessing many tables. For now, I can share one data model between client and server.
Problem:
Now I need to access more than one table between client and server at the same time. I don't know how to access many shared data models at a time.
Question:
How do I access multiple tables in the Client Server Application? Any examples available?
Thanks in advance.
@Admin: Thanks for your quick reply. It works like a charm now. And your new HTML documentation is much comfortable than the PDF, well done work
Thank you very much for your reply Admin.
So, whichever table I am using should contain the primary key INTEGER ID column?
@Admin: Now I have found the exact problem of not fetching from the existing table.
Problem:
In my existing table I don't have the Column name 'ID', which the REST server is expecting. While debugging in the Server side, I got to know this problem.
Question:
Can't we have a table without an 'ID' column (which is automatically created by TSQLRecord in a REST Model)? If so, how could I do it?
Thanks in advance.
Yes, I call CreateMissingTables method in my Server side. Actually, I retained most of the source code from the sample 28 Rest Server.
Question:
How/Where can I cross check whether the application reads my table records from the DB?
Thanks for your reply. I am using the latest 1.18 nightly build version of the source code.
In the IDE debugger, it says JSON Format is False and I couldn't see computed SQL and JSON.
Problem:
For your information, the Table which I am accessing is not created through mORMot (REST Model). It means I am trying to access the existing Table (which I have created manually) from my DB.
Working Scenario:
If I am retrieving a Table record which is created through mORMot (REST Model), then I can retrieve those table records.
Kindly let me know if I am confusing or you couldn't understand. Thanks in advance.
Hi!
I am working with a small application in which I have to retrieve my existing Table records from Server to Client using mORMot. I have followed Sample 28, which is a bit similar to my application.
Problem:
Now I have a problem while retrieving my table records. I am using 'TSQLRecord. CreateAndFillPrepare' pattern, but it returns a NULL value in all the fields of my table records.
Below I have shared my Client and REST Model source code in which I think I have some issues. The Server Source Code is working fine.
Client Source Code:
var
aList: TObjectList<TRows>;
begin
aModel := fetchModel;
try
aClient := TSQLHttpClientWinHTTP.Create('localhost', SERVER_PORT, aModel);
aRow := TRows.CreateAndFillPrepare(aClient, 'Side LIKE ?', ['A']); // while Debugging, all the fields in aRow contains null value in this line.
try
while aRow.FillOne do
ShowMessage('Row ID: ' + IntToString(aRow.RowsID));
finally
aRow.Free;
end;
finally
aClient.Free;
end;
REST Model Source Code:
TRows = class(TSQLRecord)
function fetchModel: TSQLModel;
begin
Result:= TSQLModel.Create([TRows],SERVER_ROOT);
TRows.AddFilterOrValidate('RowsID', TSynValidateText.Create);
TRows.AddFilterOrValidate('PositionX', TSynValidateText.Create);
TRows.AddFilterOrValidate('PositionY', TSynValidateText.Create);
TRows.AddFilterOrValidate('Side', TSynValidateText.Create);
end;
Kindly waiting for some solutions to this issue. Please have patience with me!
Thanks in advance.
Thanks @DigDriver, it works now
Hi!
I am just trying to run the mORMot Sample 28. I have installed Postgre 9.3 and created DataSourceName for PostgreSQL Unicode(x64) driver in ODBC Data Source Administrator.
My Postgre Data source name is 'PostgreSQL35W' and I don't know where to mention this Data source name in this below sample code?
My Source Code:
aProps := TODBCConnectionProperties.Create('','Driver=PostgreSQL Unicode'+
{$ifdef CPU64}'(x64)'+{$endif}';Database=postgres;'+
'Server=localhost;Port=5433;UID=postgres;Pwd=password','','');
Error:
First chance exception at $763DC42D. Exception class EODBCException with message
'TODBCLib error: [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0)
'.
Process RESTserver.exe (2300)
My Question:
In the above Source Code, I gave all my Postgre credentials as it is. But where do I give Data source name which I have created in ODBC Data Source Administrator?
And my doubt was, without mentioning this DSN name how could the program knows which driver or database does we have?
Thanks in advance.
Sorry, I was confused between the REST Server and MSSQL Server in that part.
Actually, now I am following the Sample 28. But I got an error 'A connection with the server could not be established'.
Code where the program breaks:
While debugging, the program breaks in the mORMot unit which follows
function TSQLRestClientURI.EngineAdd(TableModelIndex: integer;
const SentData: RawUTF8): integer;
var P: PUTF8Char;
url, Head: RawUTF8;
begin
result := 0;
url := Model.URI[Model.Tables[TableModelIndex]];
if URI(url,'POST',nil,@Head,@SentData).Lo<>HTML_CREATED then
exit; // response must be '201 Created'
In the above code 'url' value is 'root/TRecord' and '@SentData' value is '{'JSON values of my TRecord'}'
And to be more detailed about this error code is followed,
function TSQLRestClientURI.ServerTimeStampSynchronize: boolean;
var status: integer;
aResp: RawUTF8;
begin
fServerTimeStampOffset := 0.0001; // avoid endless recursive call
status := CallBackGet('TimeStamp',[],aResp); // exactly on this line the error throws
I could only find where was the error, but don't know exactly what the error was?
Let me know if you couldn't understand anywhere in this question.
Thanks in advance.
Thanks for your suggestion, with administration rights our application runs. But again, there is a problem with the URL.
Error: Class EWinHTTP with message 'winhttp.dll error 12005 (The URL is invalid)'
My Code, related to this error:
aClient := TSQLHttpClientWinHTTP.Create('.\SQLEXPRESS',SERVER_PORT,aModel); //Server is '.\SQLEXPRESS', Server_Port is 888 and aModel is a DataModel function from RESTModel.
aClient.Add(aObject,true); //aObject is the RESTModel object.
In the above code if I change the server to 'localhost' instead of '.\SQLEXPRESS', then I got an error 'A connection with the server could not be established'.
Any solutions for this issue?
Thanks in advance.
Thanks for your reply. I have changed as you said, but now the problem with HttpSetServiceConfiguration.
Error: project raised exception class EHttpApiServer with message 'HttpSetServiceConfiguration failed: The parameter is incorrect (87)'.
The coding part is:
aHttpServer: TSQLHttpServer;
aHttpServer := TSQLHttpServer.Create(SERVER_PORT,[aRestServer],'+',useHttpApiRegisteringURI);
Here SERVER_PORT:= 888 and aRestServer:= TSQLRestServerDB.Create(aModel,':memory:',false);
Thanks in advance.
TSQLRestServer code:
aModel := DataModel; //Here DataModel is my RESTModel function
aRestServer: TSQLRestServerDB;
aRestServer:= TSQLRestServerDB.Create(aModel,':memory:',false);
Above I have followed just like the sample 28.
TOleDBConnectionProperties code:
aProps: TSQLDBConnectionProperties;
aProps := TOleDBMSSQLConnectionProperties.Create('ComputerUserName\SQLEXPRESS','Test','username','password');
As I said earlier, I don't how to access localhost connection for MSSQL database, so I have used my local database ServerName: 'ComputerUserName\SQLEXPRESS' and my Database name: 'Test'.
@ChinaPeng: Thanks for your reply. I have another question, but I don't know whether it's a stupid question.
Question: How could I access the MSSQL local database in localhost or 127.0.0.1?
I have enabled tcp protocol(port: 1433) in mssql server configurations and mssql server is running perfectly. But I don't know how to access it in a localhost or 127.0.0.1.
@Admin: Thanks and I am using TOleDBConnectionProperties as defined in SynOleDB.pas in my application. Can you also answer my above mentioned question if possible.
Thanks in advance.
Hi!
I am working with a basic application which is similar to the '28 - Simple RESTful ORM Server'. But instead of PostGRE, I am using MSSQL database.
My Question: In that sample under RESTModel unit, they have a constant value as SERVER_ROOT = 'root'; SERVER_PORT = '888'; in my case for MSSQL, what could be the values of these constants?
Thanks in advance.
Hi,
We are still learning about mORMot framework and we have lots of questions coming up because it is very different what we are used to working with RAD Development.
One of the questions we have right now is: How do we actually retrieving Database Data (Records) into the Object Layer? Do you have any good sample that you can point us to?
Please have patience with us!
Thanks in advance.
Hi Again!
In that sample "28 - Simple RESTful ORM Server", they have PostgreSQL connection by default and that doesn't work for me.
Can you tell me, what I need to change in that sample 28 for MS SQL database instead of PostgreSQL? So that I can try to understand, if it works.
Thanks in advance.
Ok! Thanks, I will let you know if it works.
Thanks for your reply.
Actually, I want to get practice with mORMot framework. I don't know how to define the database (in my case MS SQL) using ORM, any idea to start from scratch?
I will also look at the samples which you have mentioned.
Hi,
I am new to this Framework in Delphi XE7. Can anyone help me with the startup?
Question: How to populate some data in a grid from MS SQL database using mORMot framework?
It will be good if any, simple examples available.
Thanks in advance.
Pages: 1