问题描述
我使用以下代码将音频文件插入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
推荐答案
这篇关于从Blob列检索音频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!