我正在与数字人物合作你是4500和oracle数据库,我遇到了将指纹模板存储到数据库的问题,这里是我的代码的一部分
string sqlInsert = "insert into mytable(ID,FINGERPRINT)";
sqlInsert += "values (:i_ID,:i_FINGERPRINT)";
OracleParameter iID = new OracleParameter();
iID.OracleDbType = OracleDbType.Varchar2;
iID.Value = textBox1.Text;
iID.ParameterName = "i_ID";
OracleParameter iFINGERPRINT = new OracleParameter();
iFINGERPRINT.OracleDbType = OracleDbType.Blob;
iFINGERPRINT.Direction = ParameterDirection.Input;
iFINGERPRINT.Value = Data.Templates[5];
iFINGERPRINT.ParameterName = "i_FINGERPRINT";
cmdInsert.Parameters.Add(iID);
cmdInsert.Parameters.Add(iFINGERPRINT);
cmdInsert.ExecuteNonQuery();
注意:Data.Templates [5]是指纹模板格式
我收到错误“无效参数绑定” 这是什么意思? 有人能帮助我吗?我该怎么办? 提前谢谢
答案 0 :(得分:0)
string path="C:\\Fingerprintimage.bmp";
FileStream fls;
fls = new FileStream(path, FileMode.Open, FileAccess.Read);
byte[] blob = new byte[fls.Length];
fls.Read(blob, 0, System.Convert.ToInt32(fls.Length));
fls.Close();
string q="";
q = "insert into mytable(ID,FINGERPRINT) values(" + 1 + ", :BlobParameter)";
OracleParameter blobParameter = new OracleParameter();
blobParameter.OracleDbType = OracleDbType.Blob;
blobParameter.ParameterName = "BlobParameter";
blobParameter.Value = blob;
cmd = new OracleCommand(q, conn);
cmd.Parameters.Add(blobParameter);
cmd.ExecuteNonQuery();