就像这些链接
我也无法在我的 informix 数据库上仅插入 byte[] 相关操作。我尝试了很多方法并浏览了 IBM 网站。但没有解释“如何使用 byte[] 使用 c# 插入 blob 列”。
“LINK 4”非常有用。但我面临着这段代码的问题。
Error: The %0 enumeration value, %1, is invalid.
At line: blob.Open(IfxSmartLOBOpenMode.ReadWrite);
if i use cmd.Parameters.Add(new IfxParameter()).Value = byteuploaded`;
这是我的代码片段。
protected void uploadfile_Click(object sender, EventArgs e)
{
string extension;
// checks if file exists
if (!_imageUpload.HasFile)
{
_resultLbl.Text = "Please, Select a File!";
return;
}
// checks file extension
extension = System.IO.Path.GetExtension(_imageUpload.FileName).ToLower();
if (!extension.Equals(".jpg") && !extension.Equals(".jpeg") && !extension.Equals(".png"))
{
_resultLbl.Text = "Only image files (.JPGs and .PNGs) are allowed.";
return;
}
try
{
// ========= This is not working ==============
string sqlQuery = "insert into db95:TestBlobUpload (id ,fileblob) values('2', 'two');";
// ========= This is working properly ==============
//string sqlQuery = "insert into db95:TestBlobUpload (id ,filetext) values('4',?);";
string connString = "Database=db95;Host=172.16.XX.XX;Server=vsXXXX;Service=88;Protocol=onsoctcp;UID=ed;Password=ca94;";
using (this.connection = new IfxConnection(connString))
{
this.connection.Open();
using (this.cmd = new IfxCommand(sqlQuery, this.connection))
{
// Start a local transaction
this.trans = this.connection.BeginTransaction(IsolationLevel.Unspecified);
// Assign transaction object for a pending local transaction
this.cmd.Transaction = trans;
try
{
IfxBlob byteuploaded = new IfxBlob(this.connection);
byteuploaded.Read(_imageUpload.FileBytes);
// ========= BOTH OF THESE are not working ==============
//cmd.Parameters.Add(new IfxParameter()).Value = data;// System.Text.Encoding.UTF8.GetString(data);
cmd.Parameters.Add(new IfxParameter()).Value = byteuploaded;// _imageUpload.FileBytes;
int res = cmd.ExecuteNonQuery();
// commiting the transaction
this.cmd.Transaction.Commit();
}
catch
{
//this.cmd.Transaction.Rollback();
}
}
this.connection.Close();
}
}
catch (Exception)
{
}
}
我使用这个 dll 作为参考并使用 IBM.Data.Informix;
特别是无法将 byte[] 添加到 blob 列。我可以做的所有其他插入/更新/删除操作。
有什么帮助吗?
我什至升级到 ibm_data_server_driver_package_win64_v10.1.exe & clientsdk.4.10.FC1DE.WIN.exe
但是我面临着 dll 兼容性的问题。无法加载“XX.XX.dll”异常来了。
我什至尝试使用执行插入查询
INSERT INTO db95@vsXXXX:testblobupload (fileblob)
VALUES (db95@vsXXXX:FILETOBLOB('C:\tmp\Untitled.png', 'client'));
并面临错误
ERROR: Smart-large-object error.
Error Code: -9810.
Smart Large Objects: No sbspace number specified.