代码之家  ›  专栏  ›  技术社区  ›  Aaron

当试图选择blob类型的列时,sqlStatement抛出一个rangeerror_2006:提供的索引超出界限

  •  2
  • Aaron  · 技术社区  · 14 年前
    var imagedata:bytearray=new bytearray();
    var headshotstation:sqlstation=new sqlstation();
    headshotstation.sqlconnection=dbconnection;
    var headshotstr:string=“从ac_images中选择headshot,其中id=”+idx;
    headshotstation.text=headshotstr;
    headshotstation.execute();
    < /代码> 
    
    

    错误引用了此块中的最后一行。我在网上找到了一些参考资料,人们无法使用从外部程序插入数据的AS3来选择blob,这正是我的确切情况。

    准确的错误跟踪是:

    rangeerror:error 2006:提供的索引超出界限。
    在flash.data::sqlstation/internalexecute()时
    在flash.data::sqlstation/execute()时
    在edu.bu::datamanager/getHeadshotImageData()[省略/datamanager.as:396]
    在edu.bu::customstudentprofileeditorwindow/edistudent()[省略/customstudentprofileeditorwindow.mxml:194]
    在edu.bu::customstudentprofileeditorwindow/profileeditor_completehandler()[省略/customstudentprofileeditorwindow.mxml:37]
    在edu.bu::customstudentprofileeditorwindow/uuu customstudentprofileeditorwindow_window1_creationcomplete()[省略/customstudentprofileeditorwindow.mxml:9]
    在flash.events::EventDispatcher/DispatcheventFunction()时
    在flash.events::EventDispatcher/Dispatchevent()时
    在mx.core::uicomponent/dispatchevent()[e:\dev\4.x\frameworks\projects\framework\src\mx\core\uicomponent.as:12528]
    at mx.core::uicomponent/set initialized()[e:\dev\4.x\frameworks\projects\framework\src\mx\core\uicomponent.as:1627]
    在mx.managers::layoutmanager/dophasedinstantiation()[e:\dev\4.x\frameworks\projects\framework\src\mx\managers\layoutmanager.as:759]
    在mx.managers::layoutManager/DopHasedInstationCallback()[e:\dev\4.x\frameworks\projects\framework\src\mx\managers\layoutManager.as:1072]
    < /代码> 
    
    

    有什么想法会导致AS3窒息的数据有什么问题吗?

    edit:I've tryed to insert the same data into a binary type field using sqlite manager 3.5 for os x with the same result.我正在使用JPG,打算尝试其他图像格式,但我不能开始猜测提供的索引是否越界,因为尝试跳转到定义只是说明它是从SWC获取的,我看不到。在我将数据分发到压缩包中并动态解压缩之前抓取吸管,这是我不想做的。

    edit 2,workaround edition:现在,我已经编写了一个快速MXML窗口,提示输入图像并将数据插入数据库。仍然想知道为什么另一个应用程序不能以sqlstation理解的方式存储blob数据。我基本上设置了几个按钮,它们提示我在数据库中需要的图像的文件路径,用readbytes()将其读取到bytearray,并使用sqlStatement将其存储到sqlite db中。然后,我就可以轻松地读回图像。

    edit 3:here is an image of the table structure.注意,当我使用flash执行数据库映像插入时,这个表正被成功使用,而不是其他一些工具,它将数据正确地存储在blob字段中,用于除flash之外的其他每个应用程序…

    错误引用了此块中的最后一行。我在网上找到了一些参考资料,人们无法使用从外部程序插入数据的AS3来选择blob,这正是我的确切情况。

    准确的错误跟踪是:

    RangeError: Error #2006: The supplied index is out of bounds.
    at flash.data::SQLStatement/internalExecute()
    at flash.data::SQLStatement/execute()
    at edu.bu::DataManager/getHeadshotImageData()[omitted/DataManager.as:396]
    at edu.bu::CustomStudentProfileEditorWindow/editStudent()[omitted/CustomStudentProfileEditorWindow.mxml:194]
    at edu.bu::CustomStudentProfileEditorWindow/profileEditor_completeHandler()[omitted/CustomStudentProfileEditorWindow.mxml:37]
    at edu.bu::CustomStudentProfileEditorWindow/___CustomStudentProfileEditorWindow_Window1_creationComplete()[omitted/CustomStudentProfileEditorWindow.mxml:9]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.core::UIComponent/dispatchEvent()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:12528]
    at mx.core::UIComponent/set initialized()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:1627]
    at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:759]
    at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1072]
    

    有什么想法会导致AS3窒息的数据有什么问题吗?

    编辑:我尝试使用SQLite Manager 3.5 for OS X将相同的数据插入二进制类型字段,结果相同。我正在使用JPG,打算尝试其他图像格式,但我不能开始猜测提供的索引是否越界,因为尝试跳转到定义只是说明它是从SWC获取的,我看不到。在我将数据分发到一个压缩包中并在运行中对其进行解压缩之前抓取吸管,这是我不想做的。

    编辑2,解决方案版本:现在,我已经编写了一个快速的MXML窗口,它提示输入图像并将数据插入数据库。仍然想知道为什么另一个应用程序不能以sqlstation理解的方式存储blob数据。我基本上设置了几个按钮,它们提示我在数据库中需要的图像的文件路径,用readbytes()将其读取到bytearray,并使用sqlStatement将其存储到sqlite db中。然后我就可以毫不费力地读回图像了。

    编辑3:这是表格结构的图像。注意,当我使用flash执行数据库映像插入时,这个表正被成功使用,而不是其他工具,它将数据正确地存储在blob字段中,用于除flash之外的其他每个应用程序…

    3 回复  |  直到 13 年前
        1
  •  3
  •   Josh Werts    13 年前

    从Air Docs中,支持Cast从Air 2.5引入非AMF斑点。我在python中创建了一个在空气中使用的数据库/blob字段,这也解决了我的问题。

    文档示例:

    stmt.text = "SELECT CAST(data AS ByteArray) AS data FROM pictures;"; 
    stmt.execute(); 
    var result:SQLResult = stmt.getResult(); 
    var bytes:ByteArray = result.data[0].data;
    

    http://help.adobe.com/en_US/as3/dev/WSd47bd22bdd97276f1365b8c112629d7c47c-8000.html

        2
  •  2
  •   Community CDub    8 年前

    我找到你的问题是因为我也遇到过同样的问题。

    我终于能够解决我的问题了也许你应该看看我的解决方案也许这可以帮助你解决你的问题: What is the first bytes in a Blob column SQlite Adobe AIR? Blob Sizeinfo?

    AdobeAir和AMF(actionscript消息格式)试图将bytearray对象存储为格式化的二进制文件,这都是错误的。因此,它添加了第一个字节12,它是字节数组的类型代码,后跟一个大小长度为int-29的整数,最后是原始数据。

    因此,如果要将二进制blob数据存储到必须由AdobeAir读取的sqlite中,则必须添加这些信息,以允许AdobeAir将所有内容转换回bytearray。

        3
  •  0
  •   Community CDub    8 年前

    谢谢这个提示,我解释了如何在这个线程中使用Java编写AMF字节。 What is the first bytes in a Blob column SQlite Adobe AIR? Blob Sizeinfo?

    希望这有帮助,

    法比恩