如何读取和写入MP3数据库 [英] how to read and write MP3 to database

查看:154
本文介绍了如何读取和写入MP3数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何读取SQL数据库的MP3。在SQL我已存储文件为二进制格式。现在我想以检索存储在SQL MP3文件,并显示在我的aspx页面。如何????

how to read MP3 from Sql database. in sql i have stored the file as binary format. now i want to retrive the Mp3 file stored in the sql and show in my aspx page. how????

请帮助...

推荐答案

在最简单的形式,这是你将如何获得原始字节,无法真正表现出更多的不知道你想要什么......

In its simplest form this is how you would get the raw bytes, can't really show any more without knowing what you want it for...

private byte[] GetMp3Bytes(string connString)
{
   SqlConnection conn = null;
   SqlCommand cmd = null;
   SqlDataReader reader = null;

   using (conn = new SqlConnection(connString))
   {
      conn.Open();

      using (cmd = new SqlCommand("SELECT TOP 1 Mp3_File FROM MP3_Table", conn))
      using (reader = cmd.ExecuteReader())
      {
          reader.Read();
          return reader["Mp3_File"] as byte[];
      }
   }
}

这篇关于如何读取和写入MP3数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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