I am creating a new version of my Datasnap server for Firemonkey apps to connect to in Delphi 10.2 Tokyo.
My main issue is that the Datasnap server must be able to connect to multiple Firebird databases. The apps will give a parameter to the server so it knows which one to use.
For know I use an .INI file for administrating my Firebird databases. On creation of the server it reads all the locations of the database files and settings.
What is the best way to safely connect to the databases in your opinion?
I've had a few ideas my self:
On device connect create new connection component and then connect to
database that the app has set in parameter. After the device disconnects close the connection and free the component from memory.
After reading the INI file create the connection components and put them in a list. Then when a device connects search for the connection with the parameter the app sends and then open the database connection. Then after the device disconnects close the connection.
Create new TDSServer per database with a set database connection and add to
list. When device connects search for the server it needs to use with the parameter the app sends. No further database connection handling is necessary.
Only opening the connection and closing.
Or something else entirely? Maybe multi-threading?
Remarks
If a new database is added to the INI file the server is restarted so it reads all settings again. So no need for accounting for new databases runtime.
I do also want to use database transactions arround calling different methods in the server. The apps send when to start/commit/rollback the transaction.
Related
I have a web application that connects to a SQL Server named instance as OLDSERVER\OLDINSTANCE. I need to redirect the traffic to NEWSERVER\NEWINSTANCE. I know you can redirect SQL Server database connections using the SQL Server Client Network Utility (cliconfig.exe) with an alias, but it doesn't seem to support aliasing connections with instances. Does anyone know if it's possible to redirect traffic from one instance to another?
I've tried the following with no luck:
1. Creating an alias in SQL Server Client Network Utility (both with and without the incoming instance name -- i.e. using just the server name and then with the server name and instance)
2. Modifying the hosts file to point to the new SQL Server.
Anyone have any ideas how to redirect instance traffic to another instance?
i cant comment, so i write an answer... and, why dont change the Connection String of your application?
I am willing to write a connection string to allow one computer connect to another computer's sql server located in the same work group.
Anyway, searching the Internet only confused me and led me to fail tries.
So, if I am willing to connect to an sql express server to a database called "Analyze", what should my connection string look like?
Create a new text file with the extension UDL in a folder.
Right click on the file and click open with "OLE DB Core Services"
Filll in the appropriate entries and save.
Open the file in notepad - voila, your connection string is in there.
Good luck.
There is a post on MSDN explaining how to connect to SQL Server express over a network.
The main points are; you need to configure SQL Server to listen for requests. This can be done using the SQL Browser. You also need to ensure the firewall will allow requests through.
I'm writing a client and TWO servers in Delphi XE8.
One server is a normal program with forms, the second is a windows service.
Both expose the same three functions: a simple "ping", a file transfer, and a query on a MS SQL 2008 R2 database.
When I use client and the "program" server, all works well, I can write a query on the client, send the query to the server, and receive data.
When I use client and the "service" server, some parts work, but if I can write a query on the client, send the query to the server, the server receives the query, but it can't access the database.
I work on a VMWare virtual machine Win7 32 bit, with Delphi XE8 and TMS Sparkle as transport system, and DBExpress ad DB access.
I have turned off antivirus and firewall.
SQL Server is well configured, protocols, ports, browser is running.
The service runs under LOCAL SYSTEM (with every other user the service can't start, I don't understand why).
I think TMS creates a thread every time it receives a request, and my code is inside this thread.
Inside the thread I create a form, a TSQLConnection with owner the form, and a TSQLQuery, and try to open the connection.
In my log I find "SQL Error Code: 53": server not found or ... (there is nothing after "or").
I suppose it could be a permission problem, but i don't know for sure.
Some ideas?
Solved: I made a mistake in the SQL password ...
I am using SQL CE 3.5 for one of my project, the front end is WPF application which process the given files and dumps the data to SQL CE database.
Presently application and DB is on same machine.
Client wants that he should be able to run the application from any machine on the network but database should remain on shared location of Server.
User will select the path to SDF file in the Application and then when any file is processed application will dump the data to database.
My question is, if keep SDF file on network shared location and access it from any machine then does it will work fine or could give problem?
actually, it is not possible - SQL CE does not support network-hosted operations: everything related to the sdf-file (temp data) is recorded to the local machine, not network source, thus server is unable to process requests correctly.
You can use SQL Express Server that acts like data storage, for the local client the only thing you need is Microsoft Synchronization library 2.1 (it also works with SQL CE 4.0 SP1)
Summarising, create the SQL CE database, fill it with tables, index them, then port it to SQL Server express, add sync module to your app (in a separate thread ofc) and that's it.
Another solution is to use MS Access DB, which allows such mess, but it is incredibly slow not to mention no way to allow simultaneous writing to the db.
I made a program that accesses a firebird DB in network environment.
I access the DB via Network in two different points of the network normally.
But if I open the two programs simultaneously this exception is thrown on the second program, which tries to connect to DB:
"Your user name and password are not definied"
How to access the firebird DB with two connections simultaneously?
This could be caused by using the embedded versionof firebird, which only allows 1 connection. Look at the filename you installed.
If that is the problem then uninstall that and install the clasic or superserver version instead
MAke sure that the Firebird database is hosted on a computer that is running the Firebird server.
ie Install Firebird Server on the computer that has the database.
Then from your client PCs where your app is installed make sure that you are accessing the database by connecting to the Firebird server. This means that whichever component your Delphi app is using to connect to the database needs to have the 'server' property set to the hostname of the database server machine.
Once this is done your apps will be making requests to the Firebird database server which knows how to handle the connections and process the SQL requests and return results.
Most db connection components should allow you to precede the database path with an ip address or hostname like this for example
MyConnection.Database := '127.0.0.1:C:\Databases\testdb.fdb';
Obviously make sure both your programs point to the same ip address or hostname and make sure the login credentials they use are defined on that firebird server.
All firebird server installations (except embedded) can handle multiple connections by default (even using the same user), you shouldn't have to worry about that. Just make sure the client programs are using inputs (ie. db network path and firebird server login credentials) that apply on the server they are trying to connect to. You could just use SYSDBA until you get the connection under control, then start thinking about creating a unique login for your client apps to use.
In the TIBDatabase component, you have to fill the Params property with:
user_name=sysdba
password=masterkey
The Firebird installation in every computer in the LAN has to be set to this default parameters. The computer with problem must have a different access credential.
You have to uninstall Firebird and them reinstall the latest version using the service and super server options, and mark the "use gdi32.dll for retro..."
Tell me if that worked out for you.