Pregunta

Having an issue getting started with syncing sqllite db with zumero (using xamarin.ios). I have setup my sync command :

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());

but am getting an exception:

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 ()

I have set the dbName with this:

string personalFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
string dbName = "***.db";
string dbPath = Path.Combine ( personalFolder, dbName);

var conn = new SQLiteConnection ("Data Source=" + dbPath); 
conn.Open (); 
conn.ZumeroRegister();

Hopefully someone can see what I am doing incorrectly? Thanks.

¿Fue útil?

Solución

The first problem I see, which is probably not responsible for the error you are getting:

The dbfile argument to zumero_sync() needs to be the name of the dbfile on the server, which is different from the name/path of the corresponding dbfile on the client.

From your code snippets, it looks like you may be passing dbPath to new SQLiteConnection(), which is correct, but also passing the same string into the @dbfile parameter, which would be, er, less correct. :-)

On the client, management of the SQLite file is your responsibility, and Zumero does not care. Files are identified, of course, by their path.

On the server, management of the SQLite file is entirely handled by the server, and files are identified by a name. The namespace is flat, and the naming rules are strict. A dbfile name on the server must contain only lower-case letters and digits, and it must begin with a lower-case letter.

As for the error, I'm wondering if the SQLite file exists? Here's a snippet from the Tasky sample:

    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;
    }

Hoping this helps.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top