流阅读器 [英] streamreader

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

问题描述

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 with it
      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();



我犯了这样的错误,即字符串或二进制数据将被截断.
该声明已终止.
在执行非查询..



i got this erroe that String or binary data would be truncated.
The statement has been terminated.
in execute non query ..

推荐答案

请检查Words列的大小.
最大化它.
Please check the size of column of Words.
maximize it.


澄清????
1. while循环结束的地方???

2.为什么要在for循环之后再次读取
Clarify ????
1. where the while Loop is ends???

2. why you are again reading the
s = trs.ReadLine();

?

3."x"的变量范围是什么?

after for loop?

3. what is scope of variable of "x"???


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

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