2013-10-03 56 views
0

我是新的Windows Azure。请帮助我。怎样写连接查询为Windows Azure

我应该怎么写这个查询:

"SELECT catchup.*,news.text from catchup,news where news.deviceID = catchup.deviceID AND news.name = '$name' ORDER BY id DESC"; 

我用这个格式来写

mssql.query('SELECT t.text, t.complete, p.description FROM ToDoItem as t INNER JOIN Priority as p ON t.priority = p.number', { 
     success: function(results) { 
      console.log(results); 
     }, 
     error: function(err) { 
      console.log("error is: " + err); 
    }); 

但它给错误代码500怎么也传递参数。

回答

0
var sql = "SELECT t.text, t.complete, p.description FROM ToDoItem as t INNER JOIN Priority as p ON t.priority = p.number AND t.text = ?"; 
var name = '$name'; 

mssql.query(sql, [name], { 
     success: function(results) { 
     console.log(results); 
     }, 
     error: function(err) { 
       console.log("error is: " + err); 
     } 
    }); 
+0

哎蒂亚戈! thanx的帮助,但仍显示错误错误域= NSURLErrorDomain代码= -1000 “错误的URL” 的UserInfo = {0x1f57dae0 = NSLocalizedDescription坏URL,NSUnderlyingError = 0x1e5e1680 “坏URL”,com.Microsoft.WindowsAzureMobileServices.ErrorRequestKey = } – user2656303

+0

从本地SQL Server Management Studio连接到SQL数据库,并执行所创建的查询,看看它是否工作 –