开发者

Example of blob storage and retrieval in mysql for an audio file using C#

开发者 https://www.devze.com 2023-02-17 07:29 出处:网络
Can anyone give me an example of how t开发者_StackOverflow中文版o use BLOB in MySQL? For example, how to insert value into a table if the data type is declared as BLOB.

Can anyone give me an example of how t开发者_StackOverflow中文版o use BLOB in MySQL?

For example, how to insert value into a table if the data type is declared as BLOB.

This is for an audio file.


Just an example how to get a BLOB:

private byte[] GetBlob(MySqlDataReader rd, string field, Int32 len)
{
    byte[] ret = new byte[len];
    if (len > 0) rd.GetBytes(rd.GetOrdinal(field), 0, ret, 0, len);
    return ret;
}

To insert an audio file you could use byte[] f=File.ReadAllBytes() and then use f as parameter in an insert command.


you may want to have a look here: http://aspalliance.com/1093_Serialization_in_Database.all

also - as a side note, this site may help you as well: http://www.netmanners.com/email-etiquette/email-etiquette-101/

0

精彩评论

暂无评论...
验证码 换一张
取 消