mssql is not defined

I am using windows azure mobile services and I want to select information from the table using the mssql object in my custom API

here is a simplified version of my code. It says that mssql in not defined. How should the mssql object be defined be defined?? 

exports.get = function(request, response) {

    mssql.query('select top 1 * from Questions', {
    success: function(results) {
        console.log(results);
    }
    });
    
    
    response.send(statusCodes.OK, { message : 'Hello World!' });
};

Also The data (Questions table) I am trying to access were added to my azure sql database via entity framework and this table is not visible through the "Mobile Services: data" menu. Does it need to be??


  • Edited by GLyons12345 Tuesday, August 13, 2013 9:53 AM
August 12th, 2013 11:18pm

I don't think you can use the MSSQL object outside the "Windows Azure Management Portal."

However, you can find here an example of JavaScript interface to SQL Server:

http://stackoverflow.com/questions/857670/how-to-connect-to-sql-server-database-from-javascript

Free Windows Admin Tool Kit Click here and download it now
August 18th, 2013 6:36pm

It's a part of the request argument. Add - var mssql = request.service.mssql; Before you call it.
August 19th, 2013 12:55am

I'm getting similar problem. When I add in the var mssql = request.service.mssql; I get the error"

0x800a1391 - JavaScript runtime error: 'request' is undefined

Been rather frustrating as can see there are ways to access an Azure dbs via mobile services.  Here's the rest of my code. 

   var sql = "select Category,  sum(cost) as Total from Budget2.TodoItem ";
            sql = sql + "where  Year(createdAt2) = Year(GetDate()) and Month(createdAt2) = Month(GetDate()) ";
            sql = sql + "Group By Category;";
            var mssql = request.service.mssql;
            var showCatTotals = function (sql) { 
                     mysql.query(sql, {
                    success: function (results) {
                        todoItems = new WinJS.Binding.List(results);
                        listItems.winControl.itemDataSource = todoItems.dataSource;
                    },
                    error: function (err) {
                        var msg = new Windows.UI.Popups.MessageDialog(
                        error.request.responseText);
                        msg.showAsync();
                    }
                });
            };

Free Windows Admin Tool Kit Click here and download it now
January 7th, 2014 11:44am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics