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();
}
[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();
}
相关文章推荐
- 关于PHP浮点数你应该知道的(All 'bogus' about the float in PHP)
- 基于 Red Hat 的发行版 Oracle Linux 正式发布Oracle Linux 7.1
- Oracle Containers for J2EE远程安全漏洞(CVE-2014-0413)
- Oracle 10g R2不能使用EM的问题
- 表空间操作
- PreparedStatement中in子句的处理
- VMware下RedHat4.8_64位安装Oracle 10g RAC--简略脚本
- oracle sql日期比较
- 基于 Red Hat 的发行版 Oracle Linux 正式发布Oracle Linux 7.1
- OS block size和Oracle block size,查找OS Blocksize的方法
- oracle中创建数据库和表空间的几点总结
- 数据库自动备份脚本
- oracle的nvl函数的使用介绍
- 解决oracle用户连接失败的解决方法
- oracle的一些tips技巧
- Oracle 下的开发日积月累
- Oracle存储过程之数据库中获取数据实例
- Windows下ORACLE 10g完全卸载的方法分析
- Oracle 函数大全[字符串函数,数学函数,日期函数]第1/4页