Coder Social home page Coder Social logo

Comments (3)

peterhuene avatar peterhuene commented on September 7, 2024

Hi dingoxiong,

Thanks for reporting this. Do you have an example piece of code that demonstrates the problem?

from sqlite-net-wp8.

 avatar commented on September 7, 2024

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;

from sqlite-net-wp8.

peterhuene avatar peterhuene commented on September 7, 2024

In your code above, what is stmt when you call SQLite3.BindParameterIndex? I don't see it declared.

from sqlite-net-wp8.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.