读书人

小弟我的数据库有个数组是小弟我将e

发布时间: 2012-08-02 11:35:25 作者: rapoo

我的数据库有个数组,是我将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();

读书人网 >C#

热点推荐