如何将Word文档导入到SQL Server [英] how to import word document in to sql server

查看:577
本文介绍了如何将Word文档导入到SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


请在C#.net中提供确切的代码,以将Excel工作表,Word文档导入到SQL Server.请帮帮我.....


Please give exact code in C#.net to import excel sheet,word document in to sql server. please help me out please.....

推荐答案

否.但这并不困难:
1)在数据库中设置一个字段来保存它:IMAGE是一个要使用的字段,因为VARBINARY只能容纳8000个字节.
2)使用 File.ReadAllBytes [ ^ ]
3)连接到数据库,然后使用参数化的INSERT sql语句将字节写入数据库:
No. But it isn''t difficult:
1) Set up a field in your database to hold it: IMAGE is the one to go for as VARBINARY can only hold 8000 bytes.
2) Read the file, using File.ReadAllBytes[^]
3) Connect to your database, and write the bytes to it using a parametrized INSERT sql statement:
using (SqlCommand cmd = new SqlCommand("INSERT INTO MyTable (wordFile) VALUES (@DATA)", con))
   {
   cmd.Parameters.AddWithValue("@DATA", data);
   cmd.ExecuteNonQuery();
   }


这篇关于如何将Word文档导入到SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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