惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
GbyAI
GbyAI
aimingoo的专栏
aimingoo的专栏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
M
MIT News - Artificial intelligence
腾讯CDC
博客园 - Franky
Engineering at Meta
Engineering at Meta
C
Check Point Blog
T
The Blog of Author Tim Ferriss
有赞技术团队
有赞技术团队
Microsoft Azure Blog
Microsoft Azure Blog
MyScale Blog
MyScale Blog
I
InfoQ
Blog — PlanetScale
Blog — PlanetScale
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
N
Netflix TechBlog - Medium
Last Week in AI
Last Week in AI
S
SegmentFault 最新的问题
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
WordPress大学
WordPress大学

博客园 - surprise

首次使用Ajax 大家看一下这是.net的漏洞还是程序有问题,我一时也没搞清,只知道这问题挺怪的 - surprise - 博客园 一道Sql语句问题? 运用C#处理lob数据类型 (Oracle) 介绍一种Web上打印技术 Sql Server 中image类型迁移到Oracle 中Blob类型出现图片显示不出来,why????请博客们帮忙 windows 2000下最多可以承受有多大容量外存???? 如何使用一个不错的图表组件WebChart(免费) 太爽了博客园有论坛了? 谁能帮我 WebChart组件的使用??? 能不能在博客园内建立一块开源区呀??? 如何在类库项目中添加配置文件?????? 中文版的hibernate pdf教程下载 用Nhibernate怎么实现数据的添加、删除、修改简单程序 介绍Nhibernate网站 俺现在碰到一些问题请大家帮忙??? 俺现在有个程序需要UTC转换为当地时间,哪位大虾会呀??? 我想问一下NHibernate的问题??? 10.1我发现一个非常好的架构NHibernate,我想和大家一起研究
在C#中存储Blob类型的数据,
surprise · 2005-04-19 · via 博客园 - surprise

我现在在Oracle中写了个存储过程如下:
create or replace procedure update_student_clob(
     v_cmid     in number,     --表的主键ID
     v_geometry  in blob --新的图形对象
    )
is
    lobloc  blob;
     query_str  varchar2(1000);
begin
--取出blob对象
   query_str :='select SPHOTOfrom student where STUDENTID= :id for update ';
   EXECUTE IMMEDIATE query_str INTO lobloc USING v_cmid;
   --更新
   dbms_lob.write(lobloc, utl_raw.length(v_geometry),1, v_geometry);
 
   commit;
end;

在C#中的代码部分如下:
1.数据层
public override void  RunProcedure(string storedProcName,OracleParameter[] parameters)

  {
   cmd.CommandText=storedProcName;//声明存储过程名

   cmd.CommandType=CommandType.StoredProcedure;

   foreach(OracleParameter parameter in parameters)

   {
    cmd.Parameters.Add(parameter);
   }

   cmd.ExecuteNonQuery();//执行存储过程

  }

2.商业层
//用于存储照片,StuEntity 为实体类
public void AddStudent(StuEntity p_Entity)
  {
   DataAccess.DBOperator m_Ora = DBOperator.CreateKgInstance();
   try
   {
    //fs为创建文件流
    FileStream fs=new FileStream(p_Entity.photo,FileMode.OpenOrCreate);
    //创建了二进制数组
    byte[] blob = new byte[fs.Length];
    fs.Read(blob, 0, blob.Length);
    fs.Close();
    //studid为主键
    string m_Sql="update student set sphoto=empty_blob() where STUDENTID=1";
    m_Ora.Execute(m_Sql);
    SpExeFor(1,blob);
   }
   catch(Exception ex)
   {
    throw ex;
   }
   finally
   {
    m_Ora.Close();
   }
  }

  public void SpExeFor(int p_Studid,byte[] p_Blob)

  {
   DataAccess.DBOperator m_Ora = DBOperator.CreateKgInstance();
   try
   {
   //存储过程的参数声明
   OracleParameter[] parameters={
            new OracleParameter("v_cmid",OracleType.Int32),
            new OracleParameter("v_geometry",OracleType.Blob,p_Blob.Length),
           };
    parameters[0].Value=p_Studid;
    parameters[1].Value=p_Blob;
    m_Ora.RunProcedure("update_student_clob",parameters);
   }
   catch(Exception e)
   {
    throw e;
   }
   finally
   {
    m_Ora.Close();
   }
  }