Tom Beech
Tom Beech

Reputation: 2389

Connect to SQL Server via connection string on OS X

I've been coding in objective-c in Xcode for just over 2 days now. So please forgive me if I'm being stupid at all. I am from a C# / .NET background and am looking to extend my current solution from Windows platforms to Mac. I've searched far and wide for an answer to this requirement, and all I came up with is 'create a consumable web-service'. However, I don't want to do this.

So far, my application can parse JSON and send in via command line. One of the objects in the JSON is the SQL connection string. Now I need to be able to:

  1. Create an open connection to a simple SQL Azure database, based on the NSString containing my SQL connection string
  2. Execute a query, with parameters
  3. Close and dispose of the SQL connection

Any and all help is appreciated

Upvotes: 1

Views: 1417

Answers (2)

Tom Beech
Tom Beech

Reputation: 2389

Thanks for your answer, and even though it does point me in the right direction, as you correctly stated, there is no OSX driver for Azure from Microsoft.

Because of this reason, i feel the original question, to connect to a SQL Azure database, has not been answered.

I believe the best, and correct, way to proceed is to do what i originally did not want to do and set up a consumable web-service for the DB calls my application required.

My apologies for not up-voting your response sooner, it was an oversight, I did not intend to be rude.

Thanks again for your reply gaige

Upvotes: 0

gaige
gaige

Reputation: 17481

For talking to an SQL server from a Mac, you're going to need to have an appropriate ODBC driver, or a set of libraries that works directly with objective-c (or c).

ODBC isn't particularly well supported by OS X, so I'd avoid it unless you can find a tested and installable ODBC driver to work with it. With that said, we do make use of it in our products to talk to other (non-Azure) SQL databases and have found it stable and useful, as long as the drivers are good.

Otherwise, you're going to need to seek out an SDK that will work for you. As far as I can tell, they've open-sourced most of their SDK on github, but there isn't an OS X version there.

Upvotes: 2

Related Questions