+ Reply
Results 1 to 11 of 11

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


Thread: How to connect to microsoft sql server

is a discussion within the

OS Apps and Development

forums, a part of the

Computer Modding Software

section;
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?!
...
  1. #1
    What's Jailbreak?
    Join Date
    May 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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
    What's Jailbreak?
    Join Date
    Sep 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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
    Developer NetMage's Avatar
    Join Date
    Aug 2007
    Location
    Virginia
    Posts
    1,296
    Thanks
    72
    Thanked 210 Times in 168 Posts

    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
    Banned
    Join Date
    Mar 2012
    Posts
    73
    Thanks
    0
    Thanked 2 Times in 2 Posts

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

  6. #6
    H4CK3R's Avatar
    Join Date
    Jan 2012
    Location
    java.lang.IllegalStateException: Location unknown.
    Posts
    5,823
    Thanks
    63
    Thanked 262 Times in 251 Posts

    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?
    Great minds discuss ideas.
    Average minds discuss events.
    Small minds discuss people.

  7. #7
    Livin the i raduga's Avatar
    Join Date
    May 2009
    Posts
    1,638
    Thanks
    228
    Thanked 94 Times in 85 Posts

    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
    H4CK3R's Avatar
    Join Date
    Jan 2012
    Location
    java.lang.IllegalStateException: Location unknown.
    Posts
    5,823
    Thanks
    63
    Thanked 262 Times in 251 Posts

    Quote Originally Posted by raduga View Post
    No,
    appydavid is a spam-bot who is trying to connect us to himself.
    Sarcasm?
    Great minds discuss ideas.
    Average minds discuss events.
    Small minds discuss people.

  9. #9
    Livin the i raduga's Avatar
    Join Date
    May 2009
    Posts
    1,638
    Thanks
    228
    Thanked 94 Times in 85 Posts

    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
    H4CK3R's Avatar
    Join Date
    Jan 2012
    Location
    java.lang.IllegalStateException: Location unknown.
    Posts
    5,823
    Thanks
    63
    Thanked 262 Times in 251 Posts

    Report it and move on.
    Great minds discuss ideas.
    Average minds discuss events.
    Small minds discuss people.

  11. #11
    What's Jailbreak?
    Join Date
    Sep 2013
    Posts
    3
    Thanks
    0
    Thanked 1 Time in 1 Post
    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