对于我的应用程序,我试图在我的 SQLite 应用程序中存储一个字节数组,我正在以这种方式填充我的 SQLite 数据库:
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);
}
其中 InsertDateTime 是 DateTime.UtcNow 而 Data 是一个字节数组。此结果的输出导致字段数据包含: System.Byte [],我不能只在该字段中显示真正的字节数组,而不显示字符串吗?我在任何地方都使用 Byte[] 类型来填充数据库,所以我不会将其转换为字符串。我想在Data字段中看到这样的东西:01、54、32、23、11、02、53。数据库中Data字段的DataType是:BLOB。
谁能帮我实现这一目标?