【发布时间】:2014-04-15 14:39:35
【问题描述】:
我正在尝试将 pdf 文件记录到 firebird 数据库中,但在 firebird 中,该字段是 BLOB 类型,而 C# 代码没有此选项。按照我的代码:
public void databaseFilePut(string varFilePath) {
OleDbConnection cn = new OleDbConnection("MinhaConexao");
byte[] imagem;
FileStream fs = new FileStream(varFilePath, FileMode.Open);
BinaryReader br = new BinaryReader(fs);
long numBytes = new FileInfo(varFilePath).Length;
imagem = br.ReadBytes((int)numBytes);
string _sql = "insert into GD_ARQUIVODOC (GD_ARQDOCARQUIVO) values (?)";
cn.Open();
OleDbCommand cmd = new OleDbCommand(_sql, cn);
cmd.Parameters.Add("?", OleDbType.VarBinary).Value = imagem;
cmd.ExecuteNonQuery();
cn.Close();
这有什么问题吗?错误是:参数值不可读。为什么?有人可以帮助我吗?暂且
【问题讨论】:
-
BTW:据我所知,使用
Parameters.Add("?", ....对位置参数无效。您需要指定索引,或者什么都不指定。