【发布时间】:2015-04-21 01:39:05
【问题描述】:
我在 Mysql 上有一个存储为 BLOB 的 word 文档,我正在尝试使用 c# 读取它,获取其中的文本。有人可以给我关于如何做到这一点的简短代码。到目前为止,我已经设法使用以下方法从数据库中读取字节:
using (MySqlConnection conn = new MySqlConnection())
{
conn.ConnectionString = "connection string is here";
conn.Open();
MySqlCommand command = new MySqlCommand("select filename, document_content from job_db.person_documents where doc_type = 'application/msword' limit 1;", conn);
using (MySqlDataReader reader = command.ExecuteReader())
{
// while there is another record present
while (reader.Read())
{
Byte[] bytData = (byte[])reader[1];
}
}
conn.Close();
}
【问题讨论】:
标签: c# mysql interop blob console-application