locked
query non mobile services table server side RRS feed

  • Question

  • Hi

    I am attempting to query a normal sql table hosted in azure using mobile services, I have given the tables the permission to be seen by the mobile service as I am able to use the .read query in my javascript app which then calls the server side script function read. I know this is happening, since i was able to send a response back from that script. I have tried to implement the following on the server side for my table but it doesn't want to return anything, if I use a table created in mobile services the code below will return the record for that user.

    function read(query, user, request) { query.where({ UserName: "testuser" })
    ....

    }

    Upon further reading I then saw one can use a normal sql query so I tried that but I still dont get any results being returned, I now am getting a forbidden error using the following:

    function read(query, user, request){
    var sql = "Select * from User where UserName = 'testuser'";
    mssql.query(sql, {
            success: function(results) {
                response.send(200, results);
            }
    });
    };

    The above code is on the read script of the User table. (not sure if maybe the table name is confusing the issue)

    So somewhere I am not using the correct permissions(as the error message says forbidden), but not sure what permissions I am missing, I even changed the permissions on the tables to allow everyone read access, but that too didnt help.

    Can someone point me in the correct direction please.

    Thank you

    Sasha

    Friday, April 25, 2014 12:19 PM