Dynamic ODBC DSNs?

Hey All,

New Xojo user here :slight_smile: I’m working on a project to make a lightweight ODBC client to our large FileMaker database solution. An issue we have is that the users are highly portable (not an office based or internet hosted server) so I’m needing the ability to identify the IP/User/Pass on the client end, in order to establish a connection to the server which can be at a different IP depending upon how they set it up. These are non-techy people who use this app so want to be able to define at a login screen what IP/User/Pass they need to connect to the solution.

I’m wondering if its possible for us to do the installation of the ODBC Driver but when the app opens, dynamically create the DSN? Does anyone know of how to do this or have an example?

All the best!

Hi Chris,

The only way I know to go about doing this is to use the MBS SQL Plugin.


With the plugin you can dynamically create connection strings and don’t have to rely on setting up DSNs at all.

Then some code like this can work:

[code]connectionString _
= “Driver={FileMaker ODBC};” _

  • “Database=” + hostsData.ODBCDatabaseName + “;” _
  • “Server=” + hostsData.ODBCHost + “;” _
  • “PRT=” + hostsData.ODBCPort + “;” _
  • “UID=” + hostsData.ODBCUserName + “;” _
  • “PWD=” + hostsDataODBCPassword[/code]

Where hostsData is an instance of some ‘connectionData’ class with the needed connection information in it.

I’d suggest the UserName and Password values be the users FM credentials which they enter when the application starts.

Securing hard-coded credentials from prying eyes in a distributed app is a non-trivial effort. (they can easily be seen by looking at the compiled executable with a hex editor or text editor)

Good luck!

I don’t think you need a plugin for this. Or a DSN. Create your connection string based on user inputs. Then use something like this:

db = New ODBCDatabase ' declare db as a property in your App or in a module db.DataSource = "Driver=...;Database=... ... ..." If Not db.Connect Then ' issue a warning, call for help ... End

Suggestion: if you’re asking users to supply an IP address or domain name, maybe you can provide a short list in a menu? You can also display a friendly name this way so users can remember a simple server name. Also it may also be appropriate for your program to automatically connect to the server/database that was open previously so the “setup” only needs to be done the first time.

I should clarify, I believe the plugin is needed if you’re doing this cross-platform (MacOS has very limited ODBC support).

If you’re Windows Target only, what Eric suggests likely works.

Have never tried from Linux Target so can’t comment about it.

You do get added benefit of MBS’ excellent support (they’re quick and results oriented in my experience) if you’re using the plugin. For my business, the licensing cost is worth the saved labor time, but understand this isn’t the case for some.