本文介绍了无法更新表格中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 在我的项目中,我无法更新名为PictureFile的''image''数据类型列。 以下是我的代码: string fileName = ImagePreview.ImageUrl; int fileLength = PhotoUpload。 PostedFile.ContentLength; int v_mem_id = 158; byte [] imageBytes = new byte [fileLength]; PhotoUpload.PostedFile.InputStream。读取(imageBytes,0,fileLength); SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings [tnrestConnectionString]。ConnectionString); 尝试 { string updateSql =UPDATE member+SET PictureFile = @ a,pictureFile WHERE mem_id =+ v_mem_id +; SqlCommand UpdateCmd = new SqlCommand (updateSql,conn); UpdateCmd.Parameters.Add(@ a,SqlDbType.Image,10,PictureFile); UpdateCmd.Parameters [@ a。。Value = Convert.ToByte(fileLength).ToString(); conn.Open(); UpdateCmd.ExecuteNonQuery(); } catch(SqlException ex) { } 任何人都可以帮帮我。解决方案 In my project I am unable to update an ''image'' datatype column named as ''PictureFile''. The following is my code:string fileName = ImagePreview.ImageUrl; int fileLength = PhotoUpload.PostedFile.ContentLength; int v_mem_id = 158; byte[] imageBytes = new byte[fileLength]; PhotoUpload.PostedFile.InputStream.Read(imageBytes, 0, fileLength); SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["tnrestConnectionString"].ConnectionString); try { string updateSql = "UPDATE member " + "SET PictureFile = @a,pictureFile WHERE mem_id= " + v_mem_id + " "; SqlCommand UpdateCmd = new SqlCommand(updateSql, conn); UpdateCmd.Parameters.Add("@a", SqlDbType.Image,10, "PictureFile"); UpdateCmd.Parameters["@a"].Value = Convert.ToByte(fileLength).ToString(); conn.Open(); UpdateCmd.ExecuteNonQuery(); } catch (SqlException ex) { } Can anyone help me out. 解决方案 这篇关于无法更新表格中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-23 10:50