SQL错误:[否如表"错误、SQL、QUOT、否如表

2023-09-08 13:06:08 作者:cαō性闖兲涯~↘

我想解决为什么我的code回到我所有的疑问空,终于发现,SQL查询返回任何内容。我创建了一个新的AIR文件(S:的WindowedApplication)拥有简约code:

I am trying to troubleshoot why my code returned null for all my queries and finally found that sql query returns nothing. I created a new AIR document (s:WindowedApplication) with minimalistic code:

<fx:Script>
        <![CDATA[
            import mx.events.FlexEvent;

            private var sqlConnection:SQLConnection;
            private var select:SQLStatement;
            private var databaseFile:File;

            protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
            {
                var dbPath:String = "Movie Manager Settings/moovioDB2.db";
                databaseFile = File.userDirectory.resolvePath(dbPath);
                sqlConnection = new SQLConnection();
                select = new SQLStatement();

                sqlConnection.addEventListener(SQLEvent.OPEN, onDatabaseOpen);
                sqlConnection.openAsync();
            }

            private function onDatabaseOpen(event:SQLEvent):void
            {
                select.sqlConnection = sqlConnection;
                var query:String = "SELECT title FROM movies";
                select.text = query;
                select.addEventListener(SQLEvent.RESULT, done);
                select.execute();
            }

            private function done(event:SQLEvent):void{
                var res:SQLResult = select.getResult();
            }

        ]]>
    </fx:Script>

除此之外code孤单只是由Flex创建的标准标签。在执行我得到这个错误:

Other than this code theres is just the standard tags created by Flex. Upon execution I get this error:

Error #2044: Unhandled SQLErrorEvent:. errorID=3115, operation=execute , message=Error #3115: SQL Error. , details=no such table: 'movies'

我已经检查了2个不同的源码程序的数据库文件,并成功执行了查询。这两个'电影'表'标题'列存在。在情况下,重要的电影是3表之一,拥有超过10列全部用值present。

I have checked the database file with 2 different sqlite programs and executed the query successfully. Both 'movies' table and 'title' column exists. In case it matters movies is one of 3 tables and has over 10 columns all with values present.

我是什么做错了吗?我用同样的code(我认为)之前与预期成果,但一些修改之后,现在我甚至能得到这个基本的code在一个新的文档工作。请检查一下,看看是否我想提出一个愚蠢的错误,因为我不能看到它:)

What am I doing wrong? I used identical code(I thought) before with expected results, but after some changes now I can even get this basic code in a new document to work. Please check it out and see if I am making a stupid mistake because I can't see it :)

推荐答案

你能确认你打开数据库的路径是你检查与外部工具,文件中的一个?您可以使用 database_list编译从你内在AS3 code。只是执行它像任何其他SQL语句:

Can you verify that the path of the database you open is the one of that file you checked with external tools? You can use the database_list pragma from within you AS3 code. Just execute it as any other SQL statement:

[user@host ~]$ cd /tmp
[user@host tmp]$ sqlite3 foo.db
SQLite version 3.7.11 2012-03-20 11:35:50
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> pragma database_list;
0|main|/tmp/foo.db