Operate blob data in Oracle via C#
oracle table:
CREATE TABLE "SCOTT"."TEST_BLOB"
( "NAME" VARCHAR2(200),
"PHOTO" BLOB
)
Operating Code:
private static void OprBlob()
{
var connStr = ConfigurationManager.ConnectionStrings["ora"].ConnectionString;
using (OracleConnection conn = new OracleConnection())
{
conn.ConnectionString = connStr;
conn.Open();
var cmd = conn.CreateCommand();
cmd.CommandText = @"
begin
insert into test_blob values(:1,:2);
end;
";;
byte[] photo;
using (var fileStrm = new FileStream(@"D:\abc.png", FileMode.Open))
{
photo = new byte[fileStrm.Length];
fileStrm.Read(photo, 0, photo.Length);
}
cmd.Parameters.Add("name", OracleDbType.NVarchar2,"Phil",ParameterDirection.Input);
cmd.Parameters.Add("photo", OracleDbType.Blob, photo, ParameterDirection.Input);
cmd.ExecuteNonQuery();
}
using (OracleConnection conn = new OracleConnection())
{
conn.ConnectionString = connStr;
conn.Open();
var cmd = conn.CreateCommand();
cmd.CommandText = @"
begin
select photo into :1 from test_blob where rownum =1;
end;
"; ;
var photoParam = cmd.Parameters.Add("p", OracleDbType.Blob, ParameterDirection.Output);
cmd.ExecuteNonQuery();
byte[] photo2 = (byte[])((Oracle.DataAccess.Types.OracleBlob) photoParam.Value).Value;
using (var fileStrm = new FileStream(@"D:\phil.png",FileMode.CreateNew))
{
fileStrm.Write(photo2,0,photo2.Length);
fileStrm.Flush(true);
}
}
}
Operate blob data in Oracle via C#的更多相关文章
- How to get blob data using javascript XmlHttpRequest by sync
Tested: Firefox 33+ OK Chrome 38+ OK IE 6 -- IE 10 Failed Thanks to 阮一峰's blog: http://www.ruanyifen ...
- caffe出错:Unknown bottom blob 'data' (layer 'conv1', bottom index 0)
原文https://blog.csdn.net/u011070171/article/details/75425740 caffe训练出现如下错误: Unknown bottom blob 'data ...
- Data Base oracle常见错误及解决方案
Data Base oracle常见错误及解决方案 一.TNS协议适配器错误: 原因: 此问题的原因都是由于监听没有配置好. 解决: 1.打开oracle工具Net Manager,删除服务及监听,重 ...
- Data Base Oracle 常用命令
Data Base Oracle 常用命令 1.登录:(不需要密码,属于管理员权限) conn /as sysdba; 2.查看数据库存储位置: select name from v$datafil ...
- Manipulating Data from Oracle Object Storage to ADW with Oracle Data Integrator (ODI)
0. Introduction and Prerequisites This article presents an overview on how to use Oracle Data Integr ...
- Flashback Data Archive ( Oracle Total Recall ) introduced in 11g
Flashback Data Archive feature is part of Oracle Total Recall technology. Flashback Data Archive fea ...
- Streaming data from Oracle using Oracle GoldenGate and Kafka Connect
This is a guest blog from Robin Moffatt. Robin Moffatt is Head of R&D (Europe) at Rittman Mead, ...
- SQOOP Load Data from Oracle to Hive Table
sqoop import -D oraoop.disabled=true \ --connect "jdbc:oracle:thin:@(description=(address=(prot ...
- oracle闪回、闪回数据归档Flashback Data Archive (Oracle Total Recall)的真正强大之处、11gR2增强以及合理使用
oracle的闪回很早就出来了,准确的说一直以来应该都较少被真正用户广为使用,除了dba和极少部分开发人员偶尔用于逻辑出错.误删恢复之外,较少被用于产生更有价值的用途. 各种闪回表flashback ...
随机推荐
- LintCode Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. ...
- iphone field test 源码
Iphone工程模式读取周围BTS信息的路测程序:包括后台和界面.-iphone field test, used for reading the BTS infomation nearby. 下载地 ...
- win10-golang环境变量设置
安装go 打开环境变量 添加GOPATH 添加到path 检验 在命令指示符下->go version or go env 配置 在F:\GOPATH下放置C:\go\bin->新建pkg ...
- 如何有效的使用C#读取文件
如何有效的使用C#读取文件 你平时是怎么读取文件的?使用流读取.是的没错,C#给我们提供了非常强大的类库(又一次吹捧了.NET一番),里面封装了几乎所有我们可以想到的和我们没有想到的类,流是读取文件 ...
- PHP模版引擎 – Twig
在网站开发过程中模版引擎是必不可少的,PHP中用的最多的当属Smarty了.目前公司系统也是用的Smarty,如果要新增一个页面只需把网站的头.尾和左侧公共部分通过Smarty的include方式引入 ...
- 【python】类中__slots__使用
__slots__作用:限制类的属性,只给实例绑定任何属性和方法 如果我们想要限制class的属性怎么办?比如,只允许对Student实例添加name和age属性. 为了达到限制的目的,Python允 ...
- ASP.NET学习笔记1—— MVC
MVC项目文件夹说明 1.App_Data:用来保存数据文件 2.App_Start:包含ASP.NET-MVC系统启动的相关类文件 3.Controllers:存放整个项目"控制器&quo ...
- apache 配置多个虚拟主机,不同的端口
1.在httpd.conf添加多个端口,如下 Listen 80Listen 8080 2.开启Include conf/extra/httpd-vhosts.conf 3.具体代码如下 <Vi ...
- 随机数生成器console
#include <stdio.h> #include <stdlib.h> #include <time.h> int main() { ]; ]; int i; ...
- 使用ADD_CUSTOM_COMMAND 添加自定义命令
e.g. ADD_CUSTOM_COMMAND( TARGET world_server COMMAND cp ${CMAKE_SOURCE_DIR}/CMak ...