1. Prouso01's Avatar
    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?!
    2011-05-19 05:55 PM
  2. wil_89's Avatar
    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.
    2011-06-09 12:50 PM
  3. aoaoo0's Avatar
    Below is the code for connecting to a MSSQL Server database.

    <?php
    $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
    mssql_close($dbhandle);
    ?>
    2011-09-27 10:59 AM
  4. NetMage's Avatar
    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
    Pocket-sized Development
    Follow me on twitter: @NetMage
    2011-12-07 09:24 AM
  5. Benson11's Avatar
    But if i want to connect with DSN and MSSQL database then what code i use?
    2012-04-01 01:35 PM
  6. H4CK3R's Avatar
    I have install sql server 2000 and iis server.
    How do i connect into my database?
    Depends what you're trying to do. Are you trying to connect it to the app?
    2012-06-02 01:23 PM
  7. raduga's Avatar
    Depends what you're trying to do. Are you trying to connect it to the app?
    No,
    appydavid is a spam-bot who is trying to connect us to himself.
    2012-06-09 09:03 AM
  8. H4CK3R's Avatar
    No,
    appydavid is a spam-bot who is trying to connect us to himself.
    Sarcasm?
    2012-06-09 01:08 PM
  9. raduga's Avatar
    Sarcasm?
    The user you responded to, isn't actually a person asking a question about iOS DBI.
    It's a spammer, who pasted a nonsense comment vaguely related to the subject of the thread,
    as a pretext for pasting a link to a service they're spamming for.
    2012-06-11 01:44 AM
  10. H4CK3R's Avatar
    Report it and move on.
    2012-06-11 02:17 AM
  11. ryne661's Avatar
    Have you ever figured this out? I am trying to do the same thing.
    2013-10-06 09:33 AM
LINK TO POST COPIED TO CLIPBOARD