由于我无法控制的原因,我正在创建一个.NET2.0程序集,在其中加载一个SQLite数据库并从中检索一些二进制数据。特别是PDF文档。
将列检索为System.Data.SQLite。SQLiteBlob对象。
这将不适用于在没有ROWID的情况下创建的表-或者-如果查询不包括“ROWID”列或其别名之一,或者-如果是System.Data。SQLiteDataReader不是使用System.Data.CommandBehavior创建的。KeyInfo标志。
这是我的SQLiteCommand:
using (SQLiteCommand getBooklet = new SQLiteCommand($"SELECT \"rowid\", File_Name FROM Booklets WHERE Id = {int.Parse(key)}", dbConnection))
using (SQLiteDataReader currentCustomerReader = getBooklet.ExecuteReader(System.Data.CommandBehavior.KeyInfo & System.Data.CommandBehavior.SequentialAccess))
我调用GetBlob(inti,bool ReadOnly)函数如下:
currentCustomerPdf = currentCustomerReader.GetBlob(1, true);
我收到了这样的问候:
System.InvalidOperationException: No RowId is available
at System.Data.SQLite.SQLiteBlob.Create(SQLiteDataReader dataReader, Int32 i, Boolean readOnly)
at System.Data.SQLite.SQLiteDataReader.GetBlob(Int32 i, Boolean readOnly)
...