Discussion Locked

Delphi ADO Connection String Edirot

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I am creating an application that requires me to provide the User with the ability, at run-time, to specify the connection string parameter in order to use an TADOConnection to access databases. The issue here is that I do not know the databases towhich the User may want to connect. Therefore, I am looking for either a component (or some guidance on developing a component) that I can use that will allow the User to perform the same sort of ConnectionString editing that I can do during designtime.

2 replies

by cybergoon

I don't know if there are any components that would handle this automatically. However, If you were accessing a single database format, it might be possible to store everything except the name of the database in variable and concatentate it with the results of a TOpendialog component specifying the database name the user selected. Of course, this would only work if the database didn't reside on a server. If the database is on a server like Oracle or MS SQL Server, then you would have to prompt the user for the names of the databases.

I would recommend limiting the type of databases that the user can choose because not all database formats have the exact same field types and it could cause problems especially if you are referencing Tfields in your code.

by hawleytronics

First off, if it is an SQL database/server, then you would need to enumerate the servers on the network if you want to allow the users to select a server as well. Once they select a server, you can enumerate the databases on that server by using a Session control and pulling the names of all databases on that server from the following table: "sysdatabases" in the "master" database. The query could look something like this: 'SELECT name FROM master.dbo.sysdatabases'
You could then have a combobox control display the names from which they can select the desired database. After they select the database, you could then trigger the connection to use that particular database. I am using this method in a couple of database applications.

This discussion is closed to new replies.