错误消息:错误#3115:SQL错误。 Flash Sql数据库表错误

时间:2014-08-27 14:00:14

标签: sql flash air

我尝试使用Adobe Flash / Air从db获取一些数据。 并且它抛出错误说:

  

"错误消息:错误#3115:SQL错误。没有这样的表格' favori' "

我的代码是:

    import flash.data.SQLConnection; 
import flash.events.SQLErrorEvent; 
import flash.events.SQLEvent; 
import flash.filesystem.File; 
import flash.data.SQLResult; 
import flash.data.SQLStatement; 
import flash.errors.SQLError; 

var conn:SQLConnection = new SQLConnection(); 

conn.addEventListener(SQLEvent.OPEN, openHandler); 
conn.addEventListener(SQLErrorEvent.ERROR, errorHandler); 

// The database file is in the application storage directory 
var folder:File = File.applicationStorageDirectory; 
var dbFile:File = folder.resolvePath("debe2.db"); 

conn.openAsync(dbFile); 

function openHandler(event:SQLEvent):void 
{ 
    trace("the database was created successfully"); 
} 

function errorHandler(event:SQLErrorEvent):void 
{ 
    trace("Error message:", event.error.message); 
    trace("Details:", event.error.details); 
} 

var selectStmt:SQLStatement = new SQLStatement(); 

// A SQLConnection named "conn" has been created previously 
selectStmt.sqlConnection = conn; 
conn.openAsync(dbFile);

selectStmt.text = "SELECT id, name FROM favori"; 

selectStmt.addEventListener(SQLEvent.RESULT, resultHandler); 
selectStmt.addEventListener(SQLErrorEvent.ERROR, errorHandler2); 

selectStmt.execute(); 

function resultHandler(event:SQLEvent):void 
{ 
    var result:SQLResult = selectStmt.getResult(); 

    var numResults:int = result.data.length; 
    for (var i:int = 0; i < numResults; i++) 
    { 
        var row:Object = result.data[i]; 
        var output:String = "id: " + row.itemId; 
        output += "; name: " + row.itemName; 
        trace(output); 
    } 
} 

function errorHandler2(event:SQLErrorEvent):void 
{ 
     trace("Error message:", event.error.message); 
    trace("Details:", event.error.details); 
}
用Google搜索,大多数人都有同样的问题...... 我用几个程序检查了我的数据库它看起来很好,我看到我的桌子就在那里。 对此有什么想法吗?

1 个答案:

答案 0 :(得分:0)

它的路径问题。

你必须找到&#34; applicationStorageDirectory&#34;路径和其中的db文件。 我将其更改为&#34; desktopDirectory&#34;它为我解决了......