Firebird的文档意味着您可以将大型(> 60K)字符串写入表中的blob值。所以,如果你有这样的:是否可以向Firebird blob写入大字符串?
CREATE TABLE MyBlobTable (
theId int PRIMARY KEY NOT NULL,
theBlob BLOB SUB_TYPE 1
)
那么这应该工作:
insert into MyBlobTable (theId, theBlob) values (1, '[60K characters in a string]')
(例如通过http://web.firebirdsql.org/dotnetfirebird/blob-sub_type-1-reading-example-csharp.html启发)
但我发现,无论是C#司机也不FlameRobin可以写这个值。你得到“命令的意外结束”(指着现场约32K到字符串,这是一个有点怀疑)
我想有引用或逃跑的数据值,或者一个C#相当于一种特殊的方式这个Java代码(http://www.firebirdfaq.org/faq372/)将二进制文件直接读入语句中。我没有对文本数据做任何事情,所以我打算将它作为二进制blob存储,如果需要的话。
谢谢!
更新:“参数化查询”是我正在寻找的短语。我在做什么:
FbParameter param = new FbParameter("@blobVal", FbDbType.Text);
param.Value = myLargeString;
String query = "insert into MyBlobTable (theId, theBlob) values (1, @blobVal)";
using (FbConnection conn = [something from my pool]) {
using (FbCommand cmd = new FbCommand(query, conn)) {
cmd.Parameters.Add(param);
cmd.ExecuteNonQuery();
}
}
你能提醒我们SUBTYPE 1是什么吗?无论如何,请尝试使用参数。 – 2011-12-18 17:51:43
BLOB SUB_TYPE 1映射到C#中的字符串,而BLOB映射到字节数组。 – 2011-12-18 18:20:02