【发布时间】:2013-02-25 09:43:35
【问题描述】:
我有一个 SQLiteDatabas,我想将我的 byte[] 存储在一个名为“Data”的字段中,此时我使用的 Datetype 称为:Blob,将 Byte 数组存储在 SQLiteDatabase 中的方法看起来像这个:
public bool InsertMessage()
{
//create string SQl and fill it with the SQLite query for inserting a message.
string SQL = "Insert into ClockMessages(InsertDateTime, SendDateTime, Data) Values('"+ insertdatetime + "', null, '" + data + "');";
List<SQLiteParameter> pars = new List<SQLiteParameter>();
pars.Add(new SQLiteParameter("InsertDateTime", insertdatetime));
pars.Add(new SQLiteParameter("Data", data));
//send the SQl query and it's parameters to the SQLiteDatabase class
return SQLiteDatabase.ExecuteNonQuery(SQL, pars);
}
我的 SQLiteDatabase 中的字段 Data 字段现在包含以下文本:System.Byte[]
我想将真正的 byte[] 实际存储在数据库中,我该如何实现呢?数据字段是否需要另一个 DateType?
【问题讨论】:
-
您是否将对象转换为字节数组,还是您的基础字节数组?
-
我还没有转换任何东西,我想将完整的字节数组存储在 SQLite 数据库中,但如果需要我可以将字节数组缩减为单个字节,然后存储它们
-
看起来好像有人已将您的问题标记为已回答,但我在此处找不到如何在数据放入后将数据从数据库中取回的示例。
标签: c# visual-studio sqlite bytearray