Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.
05-19-2011, 09:55 AM #1How to connect to microsoft sql server
How do i connect to microsoft sql server from objective c?! I am making an iphone application that must have an sql server connection! How can i do that?!
06-09-2011, 04:50 AM #2
I would like to know the the same thing, I am .Net developer with a bit of basic Obj C knowledge. Just a connection string would be great.
09-27-2011, 02:59 AM #3
Below is the code for connecting to a MSSQL Server database.
$myServer = "localhost";
$myUser = "your_name";
$myPass = "your_password";
$myDB = "examples";
//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");
//declare the SQL statement that will query the database
$query = "SELECT id, name, year ";
$query .= "FROM cars ";
$query .= "WHERE name='BMW'";
//execute the SQL query and return records
$result = mssql_query($query);
$numRows = mssql_num_rows($result);
echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>";
//display the results
while($row = mssql_fetch_array($result))
echo "<li>" . $row["id"] . $row["name"] . $row["year"] . "</li>";
//close the connection
12-07-2011, 01:24 AM #4
You need some type of client library for MS SQL Server written in C/C++ that you can compile/link into your iOS code, that is not under any license incompatible with App Store rules (i.e. not GPL).
I don't think there is one readily available (thought if you could find source code for Sybase Open Client under a free license that might work).
Your best bet is to setup a Web Service intermediary between your iOS app and the SQL Server (REST, anyone?).Starlight Computer Wizardry
Follow me on twitter: @NetMage
04-01-2012, 05:35 AM #5
But if i want to connect with DSN and MSSQL database then what code i use?
06-02-2012, 05:23 AM #6
06-09-2012, 01:03 AM #7
06-09-2012, 05:08 AM #8
06-10-2012, 05:44 PM #9
06-10-2012, 06:17 PM #10
Report it and move on.Great minds discuss ideas.
Average minds discuss events.
Small minds discuss people.
10-06-2013, 01:33 AM #11
Have you ever figured this out? I am trying to do the same thing.