Hello fellow programmers
I have been searching the internet for a few days now and can't find a generic method to solve this with only ODBC and SQL.
Is there a way to see if a database already exist, only using ODBC. It has to be standard SQL because the user can chose a DSN of his choice (meaning his own SQL Server).
This means I can't check the master table on the server because they are named different on different SQL servers.
Thanks.
Don't know if this is too late, or even sufficiently "portable" for you.
I only have to deal with MS SQL, and in a past application used SELECT name FROM master.dbo.sysdatabases WHERE name = @name.
But in a new one I am using the ODBC SQLBrowseConnect (passing in server name & credentials) to get a list of databases in the server. So I just look through those. I think the original code for that was from http://www.codeproject.com/KB/database/sqlsrvenumerator.aspx.
I'm no ODBC expert, so I don't know what that requires to be running on the server (e.g. SQL Browser service) or how it compares in approach/is implemented. In fact, I wouldn't mind if anyone else comments as to whether it's any good/better! But it seems to be pure ODBC-only!