0

Azure モバイル サービス データベースがあります。サーバー側に場所フィールドを追加してデータを入れようとしています。私が使用しているソースコードは以下です。問題は、サーバーが「内部サーバー エラー」で応答し、クライアントが「MobileServiceInvalidOperationException」をスローするが、データが追加されることです。request.respond() の代わりに request.execute() を成功関数に追加すると、正常に動作しますが、テーブルに不要な行が追加されます。「内部サーバーエラー」を発生させずにデータをデータベースに入れるにはどうすればよいですか?

 function insert(item, user, request) { 
        var queryString = "INSERT INTO mytable (name, city, country, latitude, longitude, location) VALUES (?, ?, ?, ?, ?, geography::STPointFromText('POINT(' + ? + ' ' + ? + ')', 4326))";         
        mssql.query(queryString, [item.name, item.city, item.country, item.latitude, item.longitude, item.longitude.toString(), item.latitude.toString()], { 
                    success: function() {                     
                        request.respond(); 
                    }

              }); 
    }
4

2 に答える 2

0

STPointFromText() への呼び出しを queryString の外に移動します。例えば、

 function insert(item, user, request) { 
        var location = geography::STPointFromText ....
        var queryString = "INSERT INTO mytable (name, city, country, latitude, longitude, location) VALUES (?, ?, ?, ?, ?, ?)";         
        mssql.query(queryString, [item.name, item.city, item.country, item.latitude, item.longitude, location], { 
                    success: function() {                     
                        request.respond(); 
                    }

              }); 
    }

それでも問題が解決しない場合は、ログでエラーに関する追加情報を探してください。

于 2013-08-19T17:35:52.380 に答える