我用二进制方法将图片上传到数据库,想更新图片,应该怎么做。。。新手
代码:
             string name = FileUpload1.PostedFile.FileName;
             string type = name_img.Substring(name_img.LastIndexOf(".") + 1);
             Response.Write(name_img);
             Response.Write(type);
             FileStream fs = File.OpenRead(name_img);
             byte[] content = new byte[fs.Length];
             fs.Read(content, 0, content.Length);
             fs.Close();
             SqlConnection conn = new SqlConnection("server=localhost;Initial Catalog=teaching;Persist Security Info=True;Max Pool Size = 512;User ID=sa;password=123;");
             SqlCommand cmd = conn.CreateCommand();
             conn.Open();
             cmd.CommandText = "insert into img (image_Content,test) values (@content,@test)";
             cmd.CommandType = CommandType.Text;              
                 SqlParameter para = cmd.Parameters.Add("@content", SqlDbType.Image);
                 para.Value = content;
                 para = cmd.Parameters.Add("@test", SqlDbType.VarChar);
                 para.Value = test;
                 cmd.ExecuteNonQuery();
                 Label1.Text = "上传成功!";
已经插入了一条信息,我想更换掉这条信息的图片,应该怎么实现。。。。。。。。。。。
------解决方案--------------------
更新 用update啊,你只要知道主键就行,别更新了其他不改更新的
------解决方案--------------------