首页 新闻 会员 周边

80分 :C#中插入多媒体到Oracle数据库中.....急 。

0
悬赏园豆:80 [已关闭问题]

我想把上传的音频,视频文件的多媒体存到Oracle的数据库中,注意存的不是地址,而是二进制数据,我在后台把上传的文件转成字节数组后就把值付给了那个BLOB类型的数据:

 

代码
Byte [] mediaByte=new Byte[1024];
mediaByte = this.myLoad.FileBytes;

OracleConnection con = new OracleConnection("Data Source=Orcl;User ID=zj;password=zj;");

OracleCommand cmd = new OracleCommand();
cmd.Connection = con;
cmd.CommandText = "P_insert_myMedia";
cmd.CommandType = CommandType.StoredProcedure;

OracleParameter[] parms = new OracleParameter[2];
parms[0] = new OracleParameter(":media_id",OracleType.Number);
parms[1] = new OracleParameter(":mediaFile",OracleType.Blob);

parms[0].Value =10000;
parms[1].Value=mediaByte;

cmd.Parameters.AddRange(parms);

con.Open();
cmd.ExecuteNonQuery();
con.Close();

哪位帮我看下错到哪里了,我明天就要交了,急啊 。

zfy的主页 zfy | 初学一级 | 园豆:169
提问于:2010-07-27 16:06
< >
分享
其他回答(2)
0

错误提示?

Astar | 园豆:40805 (高人七级) | 2010-07-27 16:33
0

多媒体在数据库中好像类型是image,转成2进制后放进image类型字段中。如果是直接数据库编程看下这里http://database.51cto.com/art/200612/36273_1.htm

代码苦行僧 | 园豆:311 (菜鸟二级) | 2010-07-27 16:39
但是Oracle里面没有Image类型的,只有BLOB,CLOB,Bfile
支持(0) 反对(0) zfy | 园豆:169 (初学一级) | 2010-07-27 16:54
0

Byte [] mediaByte=new Byte[1024];
mediaByte = this.myLoad.FileBytes;

 

这里换成 Array.Copy(this.myLoad.FileBytes,0,mediaByte.Length,mediaByte,0);

用BLOB存储没问题,不知道你的程序报什么错误,你可以把错误贴出来,或许是存储过程的问题.

Launcher | 园豆:45045 (高人七级) | 2010-07-27 17:45
create or replace Procedure P_insert_myMedia ( media_id number, mediaFile BLOB ) as begin insert into my_media values(media_id,mediaFile); end;
支持(0) 反对(0) zfy | 园豆:169 (初学一级) | 2010-07-28 08:41
错误时数据库中的错误,ORA-06550: line 1, column 35: PLS-00103: Encountered the symbol ":" when expecting one of the following: ( - + case mod new not null <an identifier> <a double-quoted delimited-identifier> <a bind variable> avg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date <a string literal with character set specification> <a number> <a single-quoted SQL string> pipe <一个带有字符集说明的可带引号的字符串文字> <一个可带引号的 SQL 字符串> The symbol "( was inserted be ORA-06550: line 1, column 59: PLS-00103: Encountered the symbol ":" when expecting one of the following: ( - + case mod new not null <an identifier> <a double-quoted delimited-identifier> <a bind variable> avg count current exists max min prior sql stddev su
支持(0) 反对(0) zfy | 园豆:169 (初学一级) | 2010-07-28 11:45
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册