delphi android black screen (unable to connect to database) - delphi

First time I tried on Delphi 10 (Seattle) to compile an android application and got an disappointment. Its a small test application using sqlite database. Database has only one table with few records (created just for testing purposes).
I link everything right (using firedac components) and in Delphi IDE my data shows. It also compiles without an error. The application also shows on my phone (HTC M8) but right after the splash screen, the screen goes black. Nothing !
If I disconnect the FDConnection and compile then the screen shows OK on the phone (without any data ofcourse). Then I tried this way :added a button on the form which I used to open the connection and the table manually but(when run) got a firedac error (unable to open database file).
What am I missing here ? Why cant the application open the database? Is there something else I must do ? Maybe trivial but I never did an android application before.

The mobile app cannot find the database in the phone's storage. You need to create one if it does not exist. This must be done before you can connecting to the database. Basically assign the database parameter to the FDConnection in the BeforeConnect event. also ensure that FDConnection's OpenMode = CreateUTF8
procedure TMainDataModule.FDConnection1BeforeConnect(Sender: TObject);
begin
{$IFDEF ANDROID}
FDConnection1.Params.Values['Database'] := TPath.Combine(TPath.GetDocumentsPath, 'mydatabase.sdb');
{$ENDIF}
end;

After googling for some time I found the information here
mobile tutorial
that :
"The database file is not available on your mobile device unless you
copy it to the mobile device or create it on the fly."
So basically, I can not connect to my existing database on the PC from my phone.

Related

Can't connect to SQL Server in Delphi 10.3

I just installed the community version of Delphi, Delphi 10.3
I want to use FireDAC in stead of ADO,
so I want to test connections to SQL Server using FireDac but it is a complete disaster.
I dropped a FDConnection component on the form, and want to configure it to use Sql Server
There I notice I can choose from many DriverNames but not MSSQL
Why is that ?
So I tried the FireDAC Explorer but this has even more mysteries.
I add a new Connection Definition and there I can use MSSQL, but I cannot save this definition.
The save and save as button are disabled.
So I enter all the parameters I need, and yes, it opens my SQL Server database. I can see all tables, views, procedures... And I can even open a table to see the first 10 rows.
Great, if I could only save this definition...
Everytime I open the FireDAC Explorer my new definition is still there, but all parameters are not stored. I have to enter them all every time again.
But, no problem I think. I copy the parameters from the working definition and paste it in the parameters from the FDConnection on my form.
The parameters look like this
User_Name=xx
OSAuthent=No
Server=123.456.789.987\GTT
Database=DB_Test
DriverID=MSSQL
Name=DB_Test
Hm, interesting. Now it does show MSSQL as drivername. So let's set the connection property to true.
Now I get this error (allthough this is working fine in FireDAC Explorer with these parameters)
[FireDAC][Phys]-300. Driver [MSSQL] is not registered. To register it,
you can drop component [TFDPhysMSSQLDriverLink] into your project.
Well alright, if that is all I need to do.
But, it seems I don't have the component TFDPhysMSSQLDriverLink
I have others for all kind of databases, but not this one.
It seems there is something missing, but the errors don't give me much of a clue
So I am hoping there is someone here that understand the errors and can help me to fix this
EDIT
I found this question here with an accepted answer, but I don't know how to use that answer. I have no clue how to use the License manager to register FireDAC

Unable to access SQL table from appl running as service

I have a small test application, made with Delphi 10.3.1 as an Stand Alone HTTPSYS Intraweb service. It has an ADOConnection and a ADOTable and in FormShow of unit1, I open the connection, and the table and reads the first 10 rows and add them to a listbox. Just to see that it works and is possible.
When running the application as a Stand Alone HTTPSYS, vith visual GUI, it's working nicely, but when I compile it as a service, and install it, on the sql server, or on the development machine, it fails with access Violation, trying to open the table. I suppose it is an Authentication problem.
I have tried to open connection with both Windows Auth, and with a specific SQL login, and I have tried running the service with both local system (default) and with the specific SQL account.
What am I missing ?
The Specific SQL login, works in SSMS. I'm able to use it to login and access my tables.
Also, if I create the application as a DLL and put it on my IIS10, it works fine.
You are right. It has nothing to do with authentication.
For the IntraWeb HttpSys Stand Alone program to run as a service, the ServerController.ComInitialization property must be set to ciMultiThreaded.
Thanks for your comment which lead me to look elsewhere. You do deserve the credit.
Regards
Soren

Connecting to local server via dBExpress

My D7 dBExpress project is supposed to connect to a local Interbase XE7 server.
It has the usual DBX setup: SqlConnection, SqlQuery, DataSetProvider and
ClientDataSet and does a simple 'select * from mytable'.
Last time I used it, it was working fine, but today when I ran it inside the IDE,
I get an exception as I call
ClientDataSet1.Open;
in my FormCreate (that call is the entire code of the project, btw). The
exception is an EDatabaseError with msg "No mapping for Error Code Found." and happens in TSqlConnection.DoConnect
That sounds familiar - I got that error myself one time, when I went back to an IB project after a few weeks.
It turned out that in the meantime something had sneaked Firebird onto my machine and it had hijacked the port IB usually listens on, and it was actually this FB server which was rejecting the connection, not the Interbase one!
Take a look under Services to see whether there is an FB server running. If there are, close it down (and start the IB server if not already running, of course). Then try your DBX project again.
Somewhere in the IB docs, I found something which seemed to suggest there was a way of getting FB and IB servers to coexist, but to avoid falling into a similar trap another time, I wrote a couple of batch files to shut down one of them and start the other. One is called "UseIB" and contains:
net stop "Firebird server - DefaultInstance"
net start "InterBase XE7 Server gds_db"
The other one, "UseFB" just does the opposite, of course.

Datasnap Delphi XE7 - ApplyUpdates(0) issue

I have a datasnap server app developed originally with XE5 that was working fine with a client app on a mobile tablet accessing a Firebird database on a server. I have recompiled the code with XE7. The only change I had to make to the code to compile without any errors was to add DataSnap.DSProviderDataModuleAdapter to the uses of the methods unit. Have replaced the server app on the server (stop service/uninstall/reinstall/start service) and now I can no longer insert/update records in the database on the server. Whenever I reach the line of code to ApplyUpdates(0) I get the following error:
Remote Error: Access violation at address 0093CB3F in module Snackerservice.exe. Read of address 00000000.
Retrieving data from the database to display on the tablet is not a problem so the connection is working.
If I change the server app back to the one developed under XE5......all works fine again. The other strange thing is that there are no problems with the XE7 compiled app when using 'localhost' to access a copy of the database on my development machine......only when accessing through an IP connection to a server.
Can someone please help me solve this frustrating problem.
Bill Zwirs
To hopefully make it a little clearer, here is a bit of code that causes the issue:
iLic := ServerMethodsClient.Get_Licences;
iDev := ServerMethodsClient.Get_NumDevices;
if (iDev < iLic) then
begin
iDevID := ServerMethodsClient.Get_NewDevID;
MobClientDM.DevicesClient.Open;
MobClientDM.DevicesClient.Insert;
MobClientDM.DevicesClientDEVID.AsInteger:= iDevID;
MobClientDM.DevicesClientMACADDRESS.AsString := sMacAddress;
MobClientDM.DevicesClient.Post;
if (MobClientDM.DevicesClient.ChangeCount > 0) then
MobClientDM.DevicesClient.ApplyUpdates(0); ....................Error occurs here
end;
Problem solved at last.
When I installed the server app on the server I also added Midas.dll to the directory which worked fine until I compiled with XE7. So I have now included MidasLib in the uses clause of the server app and removed the Midas.dll file from the install directory. Compiled and installed and all works good again.
Hope this helps others who might have a similar problem.
Bill Zwirs

SQL Server 2012 Stored procedure is getting deleted automatically

I am having a strange problem. One of my stored procedure is getting dropped automatically.
Its not that I am creating it in a wrong place. Every time I create the SP and execute my web page, it shows. After few min, if I execute the page again, it displays a error message which is due to missing SP.
I have tried recreating again and again, and everytime it repeats. I even did restart the machine (Windows Server 2008 R2), but no use. The same procedure is fine on my SQL Server instance on Windows 8 machine.
I tried the SQL Server Profiler, but of no use. Don't see any drop procedure.
Also for some strange reason, I am getting a lot of requests every second to my SQL Server which is hosting a dotnetnuke based website. Can someone help me with this.
Thanks
Just had this issue presented by another developer. It turned out that there was a "DROP procedure" included at the end of another SP.
To look for such hidden statement in another database SP, run a statement like
select OBJECT_NAME(sc.id), sc.* from syscomments sc where text like '%<name_of_SP>%'
where <name_of_SP> is the SP being dropped.
I had this same problem, and the issue was a missing GO in the DB script between a stored procedure create script and a drop of another stored procedure.
The solution was to add a GO between stored procedure 1 create and stored procedure 2 drop.
I referred to Stored Procedure gets dropped randomly.

Resources