从Blob列检索音频文件 [英] retrieve an audio file from blob column

查看:79
本文介绍了从Blob列检索音频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码将音频文件插入oracle数据库中的blob列:
================================================== =====================
''打开文件对话框以加载音频文件
私有子Button3_Click(ByVal发送者为System.Object,ByVal e为System.EventArgs)处理Button3.Click
OpenFileDialog1.Filter =图像文件(* .mp3,*.wma,*.wav)| * .mp3; * .wma; * .wav"
OpenFileDialog1.ShowDialog()
TextBox1.Text = OpenFileDialog1.FileName
TextBox1.SelectionStart = TextBox1.Text.Length''以显示文本的最后一部分
结束子

===============================================
''将文件保存到数据库(blob列)
私有子Button2_Click(ByVal发送者为System.Object,ByVal e为System.EventArgs)处理Button2.Click
如果Trim(TextBox1.Text)="然后退出Sub

Dim stconn作为新的OracleClient.OracleConnection("User Id = oms; Password = oms; Data Source = oms;")

stconn.Open()
''将文件读入数组-简单技术
作为新IO.BinaryReader(新IO.FileStream(TextBox1.Text,IO.FileMode.Open,IO.FileAccess.Read,IO.FileShare.Read))的摘要
Dim arr()为字节= br.ReadBytes(br.BaseStream.Length)

暗淡查询为字符串
query =插入et_blob_test(file_id,blob_file)values(1,:BlobParameter)"

''将字节作为blob类型的oracle参数插入


将blobParameter设为新的OracleClient.OracleParameter()
blobParameter.OracleType = OracleClient.OracleType.Blob
blobParameter.ParameterName ="BlobParameter"
blobParameter.Value = arr

昏暗的交流作为新的OracleClient.OracleCommand(query,stconn)
comm.Parameters.Add(blobParameter)
comm.ExecuteNonQuery()

stconn.Close()

MsgBox(图像添加成功!",MsgBoxStyle.Information)
结束子
================================================== ====================

我需要检索此文件并在表格上播放.

谁能告诉我该怎么做????
请我尽可能快地使用它.

i inserted an audio file to a blob column in oracle database using the following code:
========================================================================
''open file dialog to load the audio file
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
OpenFileDialog1.Filter = "Image Files (*.mp3, *.wma, *.wav)|*.mp3; *.wma; *.wav "
OpenFileDialog1.ShowDialog()
TextBox1.Text = OpenFileDialog1.FileName
TextBox1.SelectionStart = TextBox1.Text.Length ''to show the last portion of text
End Sub

=================================================
''save the file to database(blob column)
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Trim(TextBox1.Text) = "" Then Exit Sub

Dim stconn As New OracleClient.OracleConnection("User Id=oms;Password=oms;Data Source=oms;")

stconn.Open()
''Read the file into an array - Simple Technique
Dim br As New IO.BinaryReader(New IO.FileStream(TextBox1.Text, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read))
Dim arr() As Byte = br.ReadBytes(br.BaseStream.Length)

Dim query As String
query = "insert into et_blob_test(file_id,blob_file) values(1,:BlobParameter )"

''insert the byte as oracle parameter of type blob


Dim blobParameter As New OracleClient.OracleParameter()
blobParameter.OracleType = OracleClient.OracleType.Blob
blobParameter.ParameterName = "BlobParameter"
blobParameter.Value = arr

Dim comm As New OracleClient.OracleCommand(query, stconn)
comm.Parameters.Add(blobParameter)
comm.ExecuteNonQuery()

stconn.Close()

MsgBox("Image added successfully!!", MsgBoxStyle.Information)
End Sub
=======================================================================

i need to retrieve this file and play it on the form.

can any one tell me how to do it?????
please i need it as quick as possible

推荐答案

您的代码很乱,我希望没人能在现实世界的应用程序中使用它吗? >
使用File.WriteAllBytes或类似方法将blob写入硬盘,然后可以从那里播放文件.
Your code is pretty messy, I hope no-one is going to use this in a real world application ?

Use File.WriteAllBytes or similar to write your blob to the hard drive, then you can play the file from there.


这篇关于从Blob列检索音频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆