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

help~该怎么解决

2012-01-15 
help~~~private void btnAdd_Click(object sender, System.EventArgs e){HttpPostedFile upPhotoUpPhoto.

help~~~
private void btnAdd_Click(object sender, System.EventArgs e) 

HttpPostedFile upPhoto=UpPhoto.PostedFile; 
int upPhotoLength=upPhoto.ContentLength; 
byte[] PhotoArray=new Byte[upPhotoLength]; 
Stream PhotoStream=upPhoto.InputStream; 
PhotoStream.Read(PhotoArray,0,upPhotoLength); 
 
SqlConnection conn=new SqlConnection(); 
conn.ConnectionString="server=localhost;Database=test;User Id=sa;Pwd=sa"; 
string strSql="Insert into test(FImage) values(@FImage)"; 
SqlCommand cmd=new SqlCommand(strSql,conn); 
cmd.Parameters.Add("@FImage",SqlDbType.Image); 
cmd.Parameters["@FImage"].Value=PhotoArray; 
conn.Open(); 
cmd.ExecuteNonQuery(); 
conn.Close(); 
}


报了个byte[]不能转成string 类型的错......
怎么弄啊...高手指点下....

[解决办法]
string strb = System.Text.AscIIEncoding.Deafult.GetString(b);
[解决办法]

探讨
string strb = System.Text.AscIIEncoding.Deafult.GetString(b); //将byte[] 转成 string

[解决办法]
什么地方需要将byte[] 转成 string ,就在哪里加。

热点排行