Create ODBC data source on Mac OSX

I am new to using ODBC, and I have an application which I need to connect to a Filemaker database on our server. I need to eventually distribute this application to several coworkers, and I would prefer not to have to set up the data sources manually on each machine (especially as the data needs may change as the application evolves). Is there a way to edit the data sources through a shell script?

I have checked the /Library/ODBC/odbc.ini file, and it looks like I could easily add the information I need (assuming this is the only file I would need to edit to set up the data sources), but is there any issue editing this file directly?

Editing /Library/ODBC/odbc.ini should work fine (that’s how I copy setups from one machine to another, and I have never had any issue). I’m pretty sure that all the GUI tools do is modify the config files.

A while ago I had some code for connecting to Filemaker client via OBC. As far as I remember the connection could be done in code. Do you want me to dig out the code?

Thanks, I just tested copying the contents of the ODBC folder to another machine, and it worked as expected, so that’s probably how I will go for now, until I decide if it’s worth the time to either have the application copy the necessary files into that folder during startup or parse the contents of the .ini file and write the necessary info into the file.

Thanks again.

You might be able to create the ODBC connection entirely in code and not have to mess with the ini file at all

Something like

SqlStr=“Provider=SQLOLEDB;Driver={SQL Server};Server=192.168.0.31;Database=csc;Trusted_Connection=yes;”

which works on Windows - you should be able to do something similar on OS X

I didn’t know that was an option, I thought the data sources had to be setup for the connection to work, and the ODBC connection used the setting from the data source. Does that mean that I can just give the address, driver & other data to the ODBCDatabase object directly without having to set up the data source first?

[quote=54225:@Norman Palardy]You might be able to create the ODBC connection entirely in code and not have to mess with the ini file at all

Something like

SqlStr=“Provider=SQLOLEDB;Driver={SQL Server};Server=192.168.0.31;Database=csc;Trusted_Connection=yes;”

which works on Windows - you should be able to do something similar on OS X[/quote]
Thanks, I’ll look into that. And I still have the option to use the .ini files that I have setup if I need to until I can get that working.

Sorry, I missed your post the first time. I believe I have what I need right now, so no need to spend any time looking for what you have, but I wouldn’t mind seeing your code if you happen to come across it,

[quote=54225:@Norman Palardy]You might be able to create the ODBC connection entirely in code and not have to mess with the ini file at all

Something like

SqlStr=“Provider=SQLOLEDB;Driver={SQL Server};Server=192.168.0.31;Database=csc;Trusted_Connection=yes;”

which works on Windows - you should be able to do something similar on OS X[/quote]
I finally got back to this, and was able to get it working with the connection string. Thanks, that saves me having to create & maintain several data sources. Now I only to make sure the ODBC driver is installed on each client machine. This will certainly make any updates easier for me if things need to change.

I also have to find out what limitations are imposed by Filemaker (I noticed some of the calculated fields are not returning a value). I’m also not sure about fields which are autopopulated with a lookup value, if that value will be set properly (especially if it is in a related table).

I found that this string works for me:

  dim conStr as string = "Driver={FileMaker ODBC};Server=localhost;Database=ODBC Test;UID=Admin;"

Is there any way to craft the string so that it honors the db object’s Username property rather than filling it in within the string?