首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

小弟我的数据库有个数组,是小弟我将excel文件存进去的,小弟我现在想把他另存到其他地方,大家帮小弟我看看,那里写错了

2012-08-02 
我的数据库有个数组,是我将excel文件存进去的,我现在想把他另存到其他地方,大家帮我看看,那里写错了byte[]

我的数据库有个数组,是我将excel文件存进去的,我现在想把他另存到其他地方,大家帮我看看,那里写错了
byte[] imagebytes = null;
  SqlConnection con = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Studen;Data Source=.");
  con.Open();
  SqlCommand com = new SqlCommand("select top 1(excel) from Excel1", con);
  SqlDataReader dr = com.ExecuteReader();
  while (dr.Read())
  {
  imagebytes = (byte[])dr.GetValue(0);
  }
  dr.Close();
  com.Clone();
  string content;
  content = System.Text.Encoding.Default.GetString(imagebytes);
  StreamWriter sr;
  if (File.Exists("F://123.xls")) //如果文件存在,则创建File.AppendText对象
  {
  //sr = File.AppendText(FILE_NAME);
  }
  else //如果文件不存在,则创建File.CreateText对象
  {
  sr = File.CreateText("F://123.xls");
  sr.WriteLine(content);
  sr.Close();
  }

[解决办法]
System.Text.Encoding.UTF8.GetString(bytes);
[解决办法]
不懂装懂的家伙

探讨

dr.Close();
com.Clone();
string content;



dr.Close();
com.Close();
con.Close();

热点排行