SQLDatabaseMBS - Database Exception on Connect

I am building a web app and trying to connect to a remote MS SQL Server database using the MBS database plugin. The db connection is being made from the server side app. I am getting a Database Exception when executing the Connect method when running the app in the debugger on a Mac.

The exception is reporting this error message:

00000 [iODBC][Driver Manager]dlopen({/Users/cliff/Dev/FCN Middleman/FCN Cisco Middleman.debug Libs/libtdsodbc.dylib}, 6): image not foundIM003 [iODBC][Driver Manager]Specified driver could not be loaded
rc != SQL_SUCCESS
00000 [iODBC][Driver Manager]dlopen({/Users/cliff/Dev/FCN Middleman/FCN Cisco Middleman.debug Libs/libtdsodbc.dylib}, 6): image not found

The library file is located at the path shown in the error message.

You try to use libtdsodbc.dylib?

Do you have that file on your Mac?
Looks like your sample app looks for the file inside the Libs folder.

Hi Christian! I am using libtdsodbc.dylib because that’s what your documentation said to use. I just double-checked the path for the lib file and it is “/Users/cliff/Dev/FCN Middleman/FCN Cisco Middleman.debug/FCN Cisco Middleman.debug Libs/libtdsodbc.dylib”, but the exception error is reporting a slightly different path. I suppose that is the real problem. The connection string sent to the SLQDatabaseMBS has the correct path to the lib file.

Well, if anyone needs FreeTDS download, it’s here in our Libs Folder.

Second you may use code like this:

Dim libtdsodbc as Folderitem = FindFile("libtdsodbc.dylib")
Dim cs as string = "DRIVER={" + libtdsodbc.nativePath + "};Server="+Server+";UId="+User+";PWD="+Pass+";Database="+DatabaseName+";TDS_VERSION=7.2;Port="+Port
db.Option("UseAPI") = "ODBC"
db.DatabaseName = "ODBC:"+cs

Where you pass the path to the library as part of the connection string for SQLDatabaseMBS class. SQLConnectionMBS is similar.

That is exactly the code I am using. Anyone have any idea why the path reported by the ODBC driver is different than the path I init the db with?

Just to check, this is macOS or Linux?
You verified libtdsodbc.exists is true?
What is the content of cs variable?

MacOS
libtdsodbc.exists = true
cs = DRIVER={/Users/cliff/Dev/FCN Middleman/FCN Cisco Middleman.debug/FCN Cisco Middleman.debug Libs/libtdsodbc.dylib};Server=;UId=;PWD=;Database=;TDS_VERSION=7.2;Port=1433

/Users/cliff/Dev/FCN Middleman/FCN Cisco Middleman.debug Libs/libtdsodbc.dylib
/Users/cliff/Dev/FCN Middleman/FCN Cisco Middleman.debug/FCN Cisco Middleman.debug Libs/libtdsodbc.dylib

For some reason you duplicate “FCN Cisco Middleman.debug” part in the path.

The path is correct. “FCN Cisco Middleman.debug” is the debug build folder, and “FCN Cisco Middleman.debug Libs” is the library folder in the build folder, which is where libtdsodbc.dylib is located (it is copied to that location in a build step).

I just double-checked the exception error message, and it now is reporting the same path that is passed into the connection string, but it still can’t find the library file:

00000 [iODBC][Driver Manager]dlopen({/Users/cliff/Dev/FCN Middleman/FCN Cisco Middleman.debug/FCN Cisco Middleman.debug Libs/libtdsodbc.dylib}, 6): image not foundIM003 [iODBC][Driver Manager]Specified driver could not be loaded
rc != SQL_SUCCESS
00000 [iODBC][Driver Manager]dlopen({/Users/cliff/Dev/FCN Middleman/FCN Cisco Middleman.debug/FCN Cisco Middleman.debug Libs/libtdsodbc.dylib}, 6): image not found

Can you run paused to look if the file is there?
Maybe it’s a timing thing where the file is not there quick enough by copying in build script?

The file is definitely there, and it has the same permissions as all the other dylib’s in the same folder.

I guess the ODBC manager is having issues, not the plugin. I have iODBC 64-bit installed (www.iodbc.org), but when i try to set up a new DSN it doesn’t do anything.

I reinstalled iODBC Administrator and it is working a little better. It complains whenever I try to add libtdsodbc.dylib as a driver though: “libtdsodbc.dylib” cannot be opened because the developer cannot be verified.

@Christian_Schmitz - I downloaded libtdsodbc.dylib from your website.

it’s not notarized, because we can’t notarize dylib only dmgs.

You may clear quarantine with xattr -cr in Terminal yourself.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.