Results 1 to 11 of 11

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: How to connect to microsoft sql server

  1. #1
    Default How 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?!

  2. #2
    What's Jailbreak?
    Join Date
    Sep 2010
    Location
    Australia
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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.

  3. #3
    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);
    ?>

  4. #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
    Pocket-sized Development
    Follow me on twitter: @NetMage

  5. #5
    But if i want to connect with DSN and MSSQL database then what code i use?

  6. #6
    Quote Originally Posted by appydavid View Post
    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?
    I will no longer be very active here anymore due to a variety of reasons.

  7. #7
    Quote Originally Posted by X H4CK3R X View Post
    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.

  8. #8
    Quote Originally Posted by raduga View Post
    No,
    appydavid is a spam-bot who is trying to connect us to himself.
    Sarcasm?
    I will no longer be very active here anymore due to a variety of reasons.

  9. #9
    Quote Originally Posted by X H4CK3R X View Post
    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.

  10. #10
    Report it and move on.
    I will no longer be very active here anymore due to a variety of reasons.

  11. #11
    Have you ever figured this out? I am trying to do the same thing.

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •