使用SQLite数据库的Microsoft Sync Framework脱机存储

时间:2012-12-26 07:23:09

标签: android sqlite android-sqlite microsoft-sync-framework

我已遵循Microsoft Sync Framework工具和教程。

http://code.msdn.microsoft.com/Sync-Framework-Toolkit-4dc10f0e

我正在尝试使用SQLite作为我的客户端数据库,对于我的服务器我有SQL Server 2008 R2,我配置了我的服务器数据库,我能够运行一个带有浏览器缓存的示例用于本地存储。但我想使用SQLite数据库。 when clicking on the "sync" button, the SQLite database in the Android devices should be synchronized with SQL Server database。你能指导我吗?

 this.sendRequest = function (serviceUri, successCallback, errorCallback, dir) {

        TraceObj("[" + dir + " Request]:", serviceUri, this.dataObject());
        // Construct HTTP POST request
        var xmlHttp = new XMLHttpRequest();
        xmlHttp.open("POST", serviceUri);
        xmlHttp.setRequestHeader("Accept", "application/json");
        xmlHttp.setRequestHeader("Content-Type", "application/json");
        // Handle success & error response from server and then callback
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                    var res = new SyncFormatter();
                    if (res.parse(xmlHttp.responseText)) {
                        TraceObj("[" + dir + " Response]:", serviceUri, res.dataObject());
                        alert("[" + dir + " Response]:", serviceUri, res.dataObject());
                        successCallback(res);
                        return;
                    }
                }
                TraceMsg("[" + dir + " Response Error]: ", xmlHttp.status + " Response: " + xmlHttp.responseText);
                errorCallback(xmlHttp.responseText);
            }
        };
        xmlHttp.send(this.toString());
    };
}

在上面我得到 xmlHttp.status是500。

1 个答案:

答案 0 :(得分:0)

SQLLite没有开箱即用的同步提供程序,因此如果您想将其用作客户端数据库,则必须自己构建一个。

如果您已下载Sync Framework Toolkit,您将找到SQL CE的示例同步提供程序,您可以在编写自己的SQLLite同步提供程序时使用该提供程序。

相关问题