阅读Word文档 [英] reading word document

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

问题描述

openFileDialog1.ShowDialog();
textBox1.Text = openFileDialog1.FileName;
string fname = openFileDialog1.FileName;
           
TextReader trs = new StreamReader(@fname);
String s=trs.ReadLine();
s=s.ToString();
while (s != null)
{
  String x = "";

  for (int i = 0; i < s.Length; i++)
  {

    if(s[i]!=''.'')//add the required special characters along withit
    x += s[i];
  }
  s = x;
  s = trs.ReadLine();
  conn.Open();
  SqlCommand cmd = new SqlCommand("insert into C_word (Words,Category) values(''" + s +"'',''" + comboBox1.SelectedText + "'')",conn);
  cmd.ExecuteNonQuery();
  conn.Close();

}



使用此代码时出现此错误:
字符串或二进制数据将被截断.
该声明已终止.

请,有人可以清除它吗?



While using this code I got this error:
String or binary data would be truncated.
The statement has been terminated.

Please, can anyone clear it?

推荐答案

只是一个猜测,但我会说Word字段或Category字段被定义为受限字段长度字符串,对于要放入其中的数据而言太短.
Just a guess, but I''d say either the Word field or Category field is defined as a limited length string and is too short for the data you''re trying to stuff into it.


增大数据库中varchar字段的大小.
请参见此处 [
Increase the size of the varchar field in your database.
See here[^].


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

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