2

I have developed a client/server application using a firebird db and Delphi XE2. The problem is that the TSQLConnection component on the client automatically sets the HostName propery to localhost. I would like to know, how can I write code that will give the user the option to set the HostName when the client starts the first time.

I placed the TSQLConnection component on a datamodule on the client.

On the main form, I placed an option for the user to set the HostName propery with the following code assigning the value that the user entered into the TextBox:

Database.SQLServer.Params.Add('HostName='+edtHostName.Text);

But it seems that once the program starts the TSQLConnection component sets the hostname to localhost and I cannot set it to the users Hostname. Can anyone please help me

2 Answers 2

6

The hostname is not a valid property for the dbexpress firebird connections, instead you must use the the DataBase property to specify the host using one of these formats.

1) specifing the port , host and database

  server_host/port:/path/to/database.fdb

2) specifing the host and database

  server_host:/path/to/database.fdb

3) specifing only the database

/path/to/database.fdb

So using DbExpress this will look like

  SQLConnection1.Params.Values['Database']:='192.168.1.125/3050:C:\Program Files (x86)\Firebird\Firebird_2_0\examples\empbuild\EMPLOYEE.FDB';
2
  • Do you have to use the IP address, or can you enter the hostname for example SQLConnection1.Params.Values['Database']:='HostName/3050:C:\Program Files (x86)\Firebird\Firebird_2_0\examples\empbuild\EMPLOYEE.FDB';
    – Japster
    Jul 3, 2012 at 18:16
  • If the host is in a LAN, you can use the hostname without problems, but I prefer use always the IP of the host.
    – RRUZ
    Jul 3, 2012 at 18:18
0

Check embarcadero Wiki is sometimes useful

Specifying connection parameters

The Params property is a string list that lists name-value pairs. Each pair has the form Name=Value, where Name is the name of the parameter, and Value is the value you want to assign. The particular parameters you need depend on the database server you are using. However, one particular parameter, Database, is required for all servers. Its value depends on the server you are using. For example, with InterBase, Database is the name of the .gdb file, with ORACLE it is the entry in TNSNames.ora, while with DB2, it is the client-side node name. Other typical parameters include the User_Name (the name to use when logging in), Password (the password for User_Name), HostName (the machine name or IP address of where the server is located), and TransIsolation (the degree to which transactions you introduce are aware of changes made by other transactions). When you specify a driver name, the Params property is preloaded with all the parameters you need for that driver type, initialized to default values. You can also add other connection parameters to the Params string list, according to your application's needs. For example, to provide Multiple Active Result Set (MARS) support to a SQL connection using the MSSQL driver, you must add a key called Mars_Connection and set its value to True. Because Params is a string list, at design time, you can double-click the Params property in the Object Inspector to edit the parameters using the String List editor. At run time, use the Params.Values property to assign values to individual parameters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.