本文整理汇总了C#中System.Data.SQLite.SQLiteCommand.GetBytes方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteCommand.GetBytes方法的具体用法?C# SQLiteCommand.GetBytes怎么用?C# SQLiteCommand.GetBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SQLite.SQLiteCommand
的用法示例。
在下文中一共展示了SQLiteCommand.GetBytes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplicationControl_Load
private void ApplicationControl_Load(object sender, EventArgs e)
{
#region read
var csb = new SQLiteConnectionStringBuilder
{
DataSource = DataSource,
Version = 3
};
using (var c = new SQLiteConnection(csb.ConnectionString))
{
c.Open();
{
var sql = "create table if not exists Table1 (ContentKey INTEGER PRIMARY KEY AUTOINCREMENT, ContentValue text not null, ContentBytes blob)";
using (var reader = new SQLiteCommand(sql, c).ExecuteReader())
{
}
}
{
var sql = "select ContentValue, ContentBytes from Table1";
var cmd = new SQLiteCommand(sql, c);
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
{
var ContentValue = reader.GetString(reader.GetOrdinal("ContentValue"));
var chunkSize = 4096;
// Get size of image data–pass null as the byte array parameter
long bytesize = reader.GetBytes(reader.GetOrdinal("ContentBytes"), 0, null, 0, 0);
// Allocate byte array to hold image data
byte[] imageData = new byte[bytesize];
long bytesread = 0;
int curpos = 0;
while (bytesread < bytesize)
{
// chunkSize is an arbitrary application defined value
bytesread += reader.GetBytes(reader.GetOrdinal("ContentBytes"), curpos, imageData, curpos, chunkSize);
curpos += chunkSize;
}
dataGridView1.Rows.Add(
"",
ContentValue,
"" + bytesize
);
}
}
}
}
#endregion
}