Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 尝试选择BLOB类型的列时,SQLStatement抛出RangeError 2006:提供的索引超出范围_Actionscript 3_Sqlite_Air_Blob - Fatal编程技术网

Actionscript 3 尝试选择BLOB类型的列时,SQLStatement抛出RangeError 2006:提供的索引超出范围

Actionscript 3 尝试选择BLOB类型的列时,SQLStatement抛出RangeError 2006:提供的索引超出范围,actionscript-3,sqlite,air,blob,Actionscript 3,Sqlite,Air,Blob,错误引用此块中的最后一行。我在网上找到了一些参考资料,人们无法使用AS3选择一个BLOB,因为该BLOB中插入了来自外部程序的数据,这正是我的情况 准确的错误跟踪是: var imageData:ByteArray = new ByteArray(); var headshotStatement:SQLStatement = new SQLStatement(); headshotStatement.sqlConnection = dbConnection; var headshotStr:St

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

准确的错误跟踪是:

var imageData:ByteArray = new ByteArray();
var headshotStatement:SQLStatement = new SQLStatement();
headshotStatement.sqlConnection = dbConnection;
var headshotStr:String = "SELECT headshot FROM ac_images WHERE id = " + idx;
headshotStatement.text = headshotStr;
headshotStatement.execute();
知道导致AS3阻塞的数据有什么问题吗

编辑:我尝试使用SQLite Manager 3.5 for OS X将相同的数据插入到二进制类型字段中,结果相同。我正在使用JPG,尝试其他图像格式,尽管我无法猜测哪个提供的索引超出了范围,因为尝试跳转到定义只是说明它是从SWC获取的,我看不见。在我将数据分发到zip中并动态解压缩之前,先抓住稻草,这是我不想做的

编辑2,变通版本:目前,我已经编写了一个快速MXML窗口,提示输入图像并将数据插入数据库。仍然想知道为什么另一个应用程序不能以SQLStatement理解的方式存储BLOB数据。我基本上设置了几个按钮,提示在数据库中输入所需图像的文件路径,用readBytes将它们读入ByteArray,并使用SQLStatement将其存储到SQLite数据库中。然后我就可以毫不费力地读回图像了

编辑3:这是表结构的图像。注意,当我让Flash做数据库图像插入时,这个表也被成功地使用了,这与其他一些工具不同,这些工具将数据正确地存储在BLOB字段中,但Flash


我发现了你的问题,因为我也经历过同样的问题

我终于能够解决我的问题了也许你应该看看我的解决方案也许这可以帮助你解决你的问题:

这都是Adobe AIR和AMF ActionScript消息格式的错误,它们试图将ByteArray对象存储为格式化的二进制文件。因此,它添加了第一个字节12,这是ByteArray的类型码,然后是一个int-29整数,表示大小长度,最后是原始数据


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

从AIR文档开始,支持CAST从AIR 2.5引入非AMF blob。我在python中创建并在Air中使用的数据库/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]

如果您认为这是一个bug,并且没有解决方案,请在Adobe的bug tracker上对该bug进行投票:它是否适用于SELECT*FROM。。。?你能给我看看你的sql表吗?我的意思是带有类型的标题请注意,只要blob类型涉及select,就会发生相同的错误,所以不,*没有帮助。我发誓文档中从来没有出现过这样的情况:谢谢!np,我在这里尝试了几个基于答案的复杂修复,然后遇到了一个简单的方法,希望确保其他人不会这样做…我假设在最初提出问题时,该功能不在空气中。我确实向Adobe提交了一个关于它的bug…但从未用任何解决方案更新过-呵呵
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;