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.
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.
Trending Web Development posts
Sort by Trending