Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sqlite 调用zumero_sync时出现异常_Sqlite_Zumero - Fatal编程技术网

Sqlite 调用zumero_sync时出现异常

Sqlite 调用zumero_sync时出现异常,sqlite,zumero,Sqlite,Zumero,在开始将sqllite db与zumero同步(使用xamarin.ios)时遇到问题。我已设置我的同步命令: cmd.CommandText = @"SELECT zumero_sync( 'main', @server_url, @dbfile, zumero_internal_auth_scheme('zumero_users_admin'), @credentials_username, @credentials_pas

在开始将sqllite db与zumero同步(使用xamarin.ios)时遇到问题。我已设置我的同步命令:

cmd.CommandText = 
    @"SELECT zumero_sync(
    'main', 
    @server_url, 
    @dbfile, 
    zumero_internal_auth_scheme('zumero_users_admin'), 
    @credentials_username, 
    @credentials_password, 
    @temp_path
    );";

cmd.Parameters.AddWithValue ("@server_url", "https://zinst*****.s.zumero.net");
cmd.Parameters.AddWithValue ("@dbfile", dbPath);
cmd.Parameters.AddWithValue ("@credentials_username", "myusername");
cmd.Parameters.AddWithValue ("@credentials_password", "*mypassword*");
cmd.Parameters.AddWithValue ("@temp_path", System.IO.Path.GetTempPath());
但我有一个例外:

Unhandled managed exception: Object reference not set to an instance of an object (System.NullReferenceException)
  at System.Data.SQLite.SQLiteConnection.GetPointer () [0x00000] in <filename unknown>:0 
  at System.Data.SQLite.SQLiteConnection.ZumeroRegister () [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Data.SQLite.SQLiteConnection:ZumeroRegister ()

希望有人能看到我做错了什么?谢谢。

我看到的第一个问题,可能与您遇到的错误无关:

zumero_sync()的dbfile参数必须是服务器上dbfile的名称,这与客户端上相应dbfile的名称/路径不同

从代码片段来看,您可能正在将dbPath传递给新的SQLiteConnection(),这是正确的,但同时也将相同的字符串传递给@dbfile参数,这可能不太正确。:-)

在客户机上,管理SQLite文件是您的责任,而Zumero并不关心。当然,文件是通过路径标识的

在服务器上,SQLite文件的管理完全由服务器处理,文件由名称标识。名称空间是平面的,命名规则是严格的。服务器上的dbfile名称必须仅包含小写字母和数字,并且必须以小写字母开头

至于错误,我想知道SQLite文件是否存在?下面是Tasky示例中的一个片段:

    private SQLiteConnection GetConnection ()
    {
        bool exists = File.Exists (_path);

        if (!exists)
        {
            SQLiteConnection.CreateFile (_path);
        }

        var conn = new SQLiteConnection ("Data Source=" + _path);

        if (!exists)
        {
            do_sync (conn);
        }

        return conn;
    }

希望这能有所帮助。

我们可以看到您实际打开/注册SQLiteConnection的代码吗?当然可以:var conn=new SQLiteConnection(“数据源=“+dbPath”);conn.Open();康涅狄格州ZumeroRegister();非常感谢您的回复。我认为文档中我不清楚的一点是:“第一个是应该同步的附加SQLite数据库的名称(通常是“main”)。这是本地数据库名称的完整路径吗?
SQLite允许将多个数据库文件附加到一个SQLite连接句柄。每一个都有名字。默认数据库名为“main”。zumero_sync()的第一个参数是附加数据库的名称,通常为“main”。SQLite数据库文件的文件系统路径不会传递给zumero_sync()。您只需将该路径作为参数传递给用于打开SQLite文件的任何函数。“zumero_sync()的第一个参数是附加数据库的名称,通常是“main”是我发现不明确的部分->名称“main”是附加数据库的别名吗?(然后在附加每个后续数据库文件时为其创建不同的名称/别名)。对不起,我没有领会这一点。
    private SQLiteConnection GetConnection ()
    {
        bool exists = File.Exists (_path);

        if (!exists)
        {
            SQLiteConnection.CreateFile (_path);
        }

        var conn = new SQLiteConnection ("Data Source=" + _path);

        if (!exists)
        {
            do_sync (conn);
        }

        return conn;
    }