SQL 错误:“没有这样的表"

SQL Error :quot;No such tablequot;(SQL 错误:“没有这样的表)
本文介绍了SQL 错误:“没有这样的表"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试解决为什么我的代码对所有查询都返回 null 的原因,最后发现 sql 查询什么都不返回.我用简约的代码创建了一个新的 AIR 文档 (s:WindowedApplication):

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>

除此代码外,只有 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 个不同的 sqlite 程序检查了数据库文件并成功执行了查询.电影"表和标题"列都存在.如果重要,电影是 3 个表之一,并且有超过 10 个列都存在值.

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.

我做错了什么?我之前使用了相同的代码(我认为)并获得了预期的结果,但现在经过一些更改后,我什至可以在新文档中使用此基本代码.请检查一下,看看我是否犯了一个愚蠢的错误,因为我看不到它:)

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 :)

推荐答案

你能验证你打开的数据库的路径是你用外部工具检查过的那个文件吗?您可以在 AS3 代码中使用 database_list pragma.就像执行任何其他 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

这篇关于SQL 错误:“没有这样的表"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)