insert 圖片上去oracle blob欄位的時候出現錯誤訊息: ‘ORA-00972: ID 太長’,但實際欄位中並無ID欄位?
目前在Oracle的圖形欄位並無法使用UpdateComp去存檔,可以用以下方法針對非Sql資料庫:
1.打開Server的設計畫面,找到UpdateComponent,在FieldAttrs中增加一項,將這個圖形欄位設定其UpdateEnable為False,這樣系統就不會去主動更改這個欄位。
2.為UpdateComponent增加兩個事件BeforeModify,AfterInsert
private void ucMaster_AfterInsert(object sender, UpdateComponentAfterInsertEventArgs e)
{
ModifyPhoto();
}

private void ucMaster_BeforeModify(object sender, UpdateComponentBeforeModifyEventArgs e)
{
ModifyPhoto();
}

private void ModifyPhoto()
{
if (ucMaster.CurrentRow["Photo"] != DBNull.Value)//Photo為blob欄位
{
string key = ucMaster.CurrentRow["EmployeeID"].ToString();//Employee為Key欄位
byte[] photo = (byte[])ucMaster.CurrentRow["Photo"];
SqlParameter param = new SqlParameter("ph", photo);
ArrayList list = new ArrayList();
list.Add(param);
ExecuteSql(string.Format("Update Employees set Photo = @ph where EmployeeID={0}", key), ucMaster.conn, ucMaster.trans, list);
}
}
若是多key:
string key1 = ucMaster.CurrentRow["Key1"].ToString();
string key2 = ucMaster.CurrentRow["Key2"].ToString();
ExecuteSql(string.Format("Update Employees set Photo = @ph where key1={0}and key2={1}", key1, key2), ucMaster.conn, ucMaster.trans, list);