Closed ghost closed 11 years ago
Hi dingoxiong,
Thanks for reporting this. Do you have an example piece of code that demonstrates the problem?
1). Add a new method in SQLiteConnection: public SQLiteCommand CreateCommand(string cmdText, Dictionary <string,string> paras){ if (!_open){ throw SQLiteException.New(SQLite3.Result.Error, "Cannot create commands from unopened database"); } else{ var cmd = NewCommand(); cmd.CommandText = cmdText; foreach (var o in paras){ cmd.Bind(o.Key, o.Value); //Binding Key and Value here! } return cmd; } }
2). Add a new method in SQLiteConnection: public int Execute(string query, Dictionary <string, string> paras){ var cmd = CreateCommand(query, paras); if (TimeExecution){ if (_sw == null){ _sw = new System.Diagnostics.Stopwatch(); } _sw.Reset(); _sw.Start(); } var r = cmd.ExecuteNonQuery(); if (TimeExecution) { _sw.Stop(); _elapsedMilliseconds += _sw.ElapsedMilliseconds; Debug.WriteLine(string.Format("Finished in {0} ms ({1:0.0} s total)", _sw.ElapsedMilliseconds, _elapsedMilliseconds / 1000.0)); } return r; }
3). then call this like: string sqltext = "select count(*) from sometable where name = :name and state=:state"; Dictionary<string, string> paras = new Dictionary <string, string> (); paras.Add("name","bear"); paras.Add("state", "1"); ...... connection.Execute(sqltext, paras);
then: SQLiteCommand.BindALL(Sqlite3Statement stmt) in this method, b.Index = SQLite3.BindParameterIndex(stmt, b.Name); this line always return 0;
In your code above, what is stmt when you call SQLite3.BindParameterIndex? I don't see it declared.
using this project on windows phone 8, with native SQLite 3.7.15.1 , sqlite3_bind_parameter_index always return 0. Any help, thank!