开始同步sqllite db和zumero时出现问题(使用xamarin.ios)。我已经设置了我的sync命令:
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 ()我用下面的代码设置了dbName:
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();希望有人能看到我做错了什么?谢谢。
发布于 2013-05-30 22:13:38
我看到的第一个问题可能不是你得到的错误的原因:
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;
}希望这能帮上忙。
https://stackoverflow.com/questions/16826765
复制相似问题