C#学习教程:使用System.Data.SQLite.SQLIteDataReader.GetBlob检索BLOB字段时出错NET2.0程序集,我在其中加载SQLite数据库并从中检索一些二进制数据。具体来说,PDF文档。System.Data.SQLite.SQLiteDataReader.GetBlob(inti,boolReadOnly)的文档说:(强调我的)将列检索为System.Data.SQLite.SQLiteBlob对象。如果查询不包含“rowid”列或其别名之一-OR-,如果System.Data.SQLiteDataReader不是用System.Data创建的,这将不适用于用ROWID-OR-标志创建的表。CommandBehavior.KeyInfo标志。这是我的SQLiteCommand:使用(SQLiteCommandgetBooklet=newSQLiteCommand($"SELECT"rowid",File_NameFROMBookletsWHEREId={int.Parse(key)}",dbConnection))我像这样实例化我的SQLiteDataReader:使用(SQLiteDataReadercurrentCustomerReader=getBooklet.ExecuteReader(System.Data.CommandBehavior.KeyInfo&System.Data.CommandBehavior.SequentialAccess))我调用GetBlob(inti,boolReadOnly)函数如下:currentCustomerPdf=currentCustomerReader.GetBlob(1,true);我对此表示欢迎:System.InvalidOperationException:System.Data.SQLite.SQLiteBlob.Create(SQLiteDataReaderdataReader,Int32i,BooleanreadOnly)在System.Data.SQLite.SQLiteDataReader.GetBlob(Int32i,BooleanreadOnly)处没有可用的RowId。..难道我做错了什么?我错过了一步吗?我需要提交错误吗?新版本中的.NET2.0是否已解决此问题?要使此代码起作用,请删除System.Data.CommandBehavior.SequentialAccess标志并至少选择rowid和blob字段。虽然keyinfo有效,但由于executereader方法的内存消耗较大(大小等于blob大小),它无法处理大型blob对象的增量blobI/O。避免大量内存使用的一种方法是在单独的查询中获取rowid并重载sqliteblob.create方法并直接传递rowid。所以如果能重载sqliteblob.create方法,基本上就不需要keyinfo了。以上是C#学习教程:ErrorwhenusingSystem.Data.SQLite.SQLIteDataReader.GetBlobtoretrievetheBLOBfieldandshareallthecontent。如果对大家有用,需要了解更多C#学习教程,希望大家多加关注——本文来自网络收藏,不代表立场,如涉及侵权,请点击右边联系管理员删除。如需转载请注明出处:
