我想将我的编辑框数据添加到本地表?

时间:2015-06-11 05:34:29

标签: android onclick smartface.io editbox

如何从editbox向本地表添加数据。我对代码onButton点击进行了很多更改。

我已添加此代码

Data.execute("insert into Sample_Table values('Name')",Pages.Page1.EditBox1.text);
alert(Pages.Page1.EditBox1.text); 

但我的数据未添加到 Sample_Table 中。 如果有人可以提供帮助,我该如何向其中添加数据。

1 个答案:

答案 0 :(得分:1)

有关于数据集查询的非常有用的文档,您应该检查它: http://www.smartface.io/developer/guides/data-network/sql-query-execution/

尝试以下代码:

var myEditbox = new SMF.UI.EditBox({
        left : "10%",
        top : "20%",
        text : ""
    });
var myButton1 = new SMF.UI.TextButton({
        left : "10%",
        top : "40%",
        text : "create insert",
        onPressed : function (e) {
            Data.execute("Create table Sample_Table (col1 int)");
            Data.execute("insert into Sample_Table (col1) values(?)", myEditbox.text);
        }
    });
var myButton2 = new SMF.UI.TextButton({
        left : "10%",
        top : "60%",
        text : "value",
        onPressed : function (e) {
            var myValue = Data.execute('select col1 from Sample_Table where rowId = 1');
            alert(myValue);
        }
    });

将这3个对象添加到您的页面,它将起作用。