日期:2014-05-18  浏览次数:20844 次

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 ,就在哪里加。