調用 getBlob
以下是引用片段:
String sqlStr = "select content from dp where id=" + ID;//content為dp中的BLOB字段,ID為主鍵
MemoryStream ms = DBClass.getBlob(sqlStr);
if (ms == null)
richTextBox.Clear();
else
...{
if (ms.Length > 0)
...{
ms.Position = 0;
try
...{
richTextBox.LoadFile(ms, RichTextBoxStreamType.RichText);
}catch...{
richTextBox.LoadFile(ms, RichTextBoxStreamType.PlainText);
}
}else
richTextBox.Clear();
}
調用setBlob
以下是引用片段:
String sqlStr = "update dp set content=:BLOB where id=" + ID;
MemoryStream ms = new MemoryStream();
richTextBox.SaveFile(ms, RichTextBoxStreamType.RichText);
if (!DBClass.SetBlob(sqlStr, ms))
...{
MessageBox.Show("保存失敗");
}