我正在使用 VB.NET 2008 和 SQL server 2005 传统的字典制作字典,用户编写单词并获取单词的翻译和发音,我面临从数据库检索部分的问题。我无法从数据库中检索声音文件。
这是我使用的代码
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
cmd.CommandText = " select voice from lang where arabic = N'" & txtFrom.Text & "'"
Dim dt As New DataTable()
'rdr = cmd.ExecuteReader()
cmd.Connection = con
Try
con.Open()
rdr = cmd.ExecuteReader
While rdr.Read
dt.Load(rdr)
Dim stream As Byte()
If stream Is DirectCast(dt.Rows(0)(1), Byte()) Then
File.WriteAllBytes("D:\mad.wma", stream)
AxWindowsMediaPlayer1.URL = "D:\mad.wma"
End If
End While
con.Close()
Catch ex As Exception
MsgBox(ex.Message)
con.Close()
End Try
End Sub