您的位置:首页 > 数据库 > Oracle

Oracle long raw字段操作 oledb方式 asp.net

2016-05-11 16:57 561 查看
数据库表结构:
[sql] view plain copy
-- Create table

create table B2C_SPXSM_CXXX

(

spid NUMBER not null,

cxxx LONG RAW

);

-- Create/Recreate primary, unique and foreign key constraints

alter table B2C_SPXSM_CXXX

add constraint PK_B2C_SPXSM_CXXX primary key (SPID);

写入数据表存储过程:
[sql] view plain copy
create or replace procedure Proc_B2C_SPXSM_CXXX(pspid in number,pcxxx in LONG RAW)

as

cnt number;

begin

select count(1) into cnt from B2C_SPXSM_CXXX where spid=pspid;

if cnt>0 then

update B2C_SPXSM_CXXX set cxxx=pcxxx where spid=pspid;

end if;

if cnt=0 then

insert into B2C_SPXSM_CXXX(spid,Cxxx) values (pspid,pcxxx);

end if;

end Proc_B2C_SPXSM_CXXX;

aspx页面写入代码:
[csharp] view plain copy
DbCommand cmd = DbHelper._DbCommand;

try

{

cmd.Connection = DbHelper._DbConnection;

cmd.Connection.Open();

cmd.CommandType = System.Data.CommandType.StoredProcedure;

cmd.CommandText = "Proc_B2C_SPXSM_CXXX";

cmd.Parameters.Add(new System.Data.OleDb.OleDbParameter("pspid", 111));

OleDbParameter parameter = new OleDbParameter("pcxxx", OleDbType.Binary);

parameter.Value = new System.Text.UnicodeEncoding().GetBytes(CKEditorControl1.Text);

cmd.Parameters.Add(parameter);

cmd.ExecuteNonQuery();

}

catch (Exception ex)

{

}

finally

{

cmd.Connection.Close();

}

aspx 页面读取代码:
[csharp] view plain copy
string sql = "select cxxx from B2C_SPXSM_CXXX where spid=?";

DbCommand cmd = DbHelper._DbCommand;

try

{

cmd.Connection = DbHelper._DbConnection;

cmd.Connection.Open();

cmd.CommandType = System.Data.CommandType.Text;

cmd.CommandText = sql;

OleDbParameter parameter = new OleDbParameter("spid", 111);

cmd.Parameters.Add(parameter);

object value = cmd.ExecuteScalar();

if (!(value is DBNull))

CKEditorControl1.Text = new System.Text.UnicodeEncoding().GetString((byte[])value);

}

catch (Exception ex)

{

}

finally

{

cmd.Connection.Close();

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息