在phonegap android中选择查询时获取Sqlitelog(23)未授权错误.....

时间:2014-04-15 10:03:30

标签: android sqlite cordova

我正在创建一个应用程序,在该应用程序中,我执行了一个选择以获取访问权限,该权限基于我想要运行另一个选择查询的权限。但是这样做时它给了我(23)没有授权的logcat错误。

var checkAccessQuery = "select * from ug_access where ug_id = '"+window.localStorage.getItem("roleId")+
                     "' and f_id = "+window.localStorage.getItem("module_id")+" and comp_code = "+window.localStorage.getItem('companyCode')+"";
 var query1 = '';
var moduleId ='';
var pkId ='';
$(function(tx){
 db.transaction(function(tx){
    tx.executeSql(checkAccessQuery,[],function(tx,results){
        var dataset = results.rows.length;
        if(dataset>0)
        {

        }else{
            window.localStorage.setItem('accessDenied',true);
            window.location.href = 'home.html';
        }
        console.log('value in module_id: '+window.localStorage.getItem('module_Id'));
        window.localStorage.setItem('sessionModuleId',window.localStorage.getItem('module_Id'));
        var innerModule  = 0;
        if(window.localStorage.getItem('innerModule') != 'undefined' || window.localStorage.getItem('innerModule') !=''  )
        {
            innerModule = window.localStorage.getItem('innerModule');
        }
        moduleId = 0;
        if(window.localStorage.getItem('module_Id') != 'undefined' || window.localStorage.getItem('module_Id') != '' )
        {
            moduleId = window.localStorage.getItem('module_Id');
        }
        pkId = 0;
        if(window.localStorage.getItem('pkIdDelete') != 'undefined' || window.localStorage.getItem('pkIdDelete') != '')
        {
            pkId = window.localStorage.getItem('pkIdDelete');
        }

        if(pkId !=0)
                {
tx.executeSql('select * from user_form',[],function(tx,result){
var dataset = result.rows.length;
console.log('length of the dynamic_form: '+dataset);
});
        }
    });
 },errorCb,sucessCb);


});

任何人都可以帮我解决这个问题。 任何想法都赞赏.. 提前谢谢。

1 个答案:

答案 0 :(得分:0)

这不是解决sqlite 23未授权错误的好方法。

db.transaction(function(tx){
tx.executeSql(checkAccessQuery,[],function(tx,results){
    var dataset = results.rows.length;
    if(dataset>0)
    {

    }else{
        window.localStorage.setItem('accessDenied',true);
        setTimeout(function() {
            window.location.href = 'home.html';
        }, 1500);

    }
});