|
请问,模糊删除里,怎么将%和参数拼起来啊,我这么写,没有用。。。。。
- var sqlConn = sqlite("/test.db");
- var command = sqlConn.prepare("delete from fileinfo where name like '%' +@keyw + '%';");
- command.bind.parameterByNamesAt(
- keyw = "I'm Jack.doc";
- ).step();
- command.finalize() ;
- sqlConn.close();
复制代码
- import win.ui;
- import sqlite;
- /*DSG{{*/
- mainForm = ..win.form(text="aardio Form";right=599;bottom=399)
- mainForm.add(
- button={cls="button";text="Insert";left=68;top=44;right=210;bottom=80;z=2};
- button2={cls="button";text="select";left=234;top=44;right=375;bottom=80;z=3};
- button3={cls="button";text="delete";left=67;top=97;right=208;bottom=137;z=4};
- edit={cls="edit";left=14;top=172;right=585;bottom=383;db=1;dl=1;dr=1;dt=1;edge=1;multiline=1;z=1}
- )
- /*}}*/
- var sqlConn = sqlite("/test.db");
- if(!sqlConn.existsTable("fileinfo"))
- {
- sqlConn.exec( "create table fileinfo(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT , path TEXT);");//创建表
- } else {
- sqlConn.exec("delete from fileinfo;DELETE FROM sqlite_sequence;");
- }
- sqlConn.close();
- mainForm.button.oncommand = function(id,event){
- //mainForm.msgbox( mainForm.button.text );
- var sqlConn = sqlite("/test.db");
- var command = sqlConn.prepare("insert into fileinfo values (null ,@name,@path);" );
-
- //绑定命名参数
- command.bind.parameterByNamesAt(
- name = "I'm Jack.doc";
- path = "E:\Computer\Desktop\Publish";
- ).step();
- //释放命令对象
- command.finalize() ;
- command = sqlConn.prepare("insert into fileinfo values (null ,@name,@path);" );
-
- //绑定命名参数
- command.bind.parameterByNamesAt(
- name = "I am Tom.doc";
- path = "E:\Computer\Desktop\Publish";
- ).step();
- //释放命令对象
- command.finalize() ;
-
- sqlConn.close();
- }
- mainForm.button3.oncommand = function(id,event){
- var sqlConn = sqlite("/test.db");
- var command = sqlConn.prepare("delete from fileinfo where name like '%' +@keyw + '%';");
- command.bind.parameterByNamesAt(
- keyw = "I'm Jack.doc";
- ).step();
- command.finalize() ;
- sqlConn.close();
- }
- mainForm.button2.oncommand = function(id,event){
- //mainForm.msgbox( mainForm.button2.text );
- var sqlConn = sqlite("/test.db");
- for id,name,path in sqlConn.each("SELECT * from fileinfo") {
- mainForm.edit.print(id, path ,name);
- }
- sqlConn.close();
- }
- mainForm.show()
- return win.loopMessage();
复制代码 |
|