Click here to Skip to main content
15,904,024 members
Please Sign up or sign in to vote.
1.50/5 (4 votes)
See more:
Image is Updating Sucessfully But i need When i am not Update Image .....1 st Time and another time i want to update image ..any thing .....
C#
con.Open();
SqlCommand cmd = new SqlCommand("UpdateUserDetailsAug7_SP", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@UserId", ViewState["UserId"]);
cmd.Parameters.AddWithValue("@UserName", txtUserName.Text);
cmd.Parameters.AddWithValue("@DateOfBirth", txtDateofBirth.Text);
cmd.Parameters.AddWithValue("@Salary", txtSalary.Text);

if (FileUploadPhoto.HasFile)
{
   fileName = FileUploadPhoto.FileName;
   filePath = Server.MapPath("~/Images/" + System.Guid.NewGuid() + fileName);
   FileUploadPhoto.SaveAs(filePath);
   fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
   br = new BinaryReader(fs);
   bytes = br.ReadBytes(Convert.ToInt32(fs.Length));
   cmd.Parameters.AddWithValue("@ImagePath", bytes);

}

cmd.Parameters.Add("@Message", SqlDbType.VarChar, 500);
cmd.Parameters["@Message"].Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
string outputValue = cmd.Parameters["@Message"].Value.ToString();
lblMessage.Text = outputValue;
lblMessage.ForeColor = System.Drawing.Color.RoyalBlue;
               
BindUserDetails();
con.Close();
Posted
Updated 13-Aug-14 3:39am
v7
Comments
Sai Prasad anumolu 10-Aug-14 8:17am    
NOTe: I used Generic Handler method
[no name] 10-Aug-14 8:18am    
And.... now what? Do you expect someone to debug all of this code for you?
Sai Prasad anumolu 10-Aug-14 8:20am    
Hi sir Give me Your EmailId i will mail you ... I need how to update Logic + when i click one dit button How to data retrive expessly gridview This is my own preparation sir
[no name] 10-Aug-14 8:31am    
No thank you. I would never give someone that I do not my email address so they can send me files that I would not know what is in them. You really need to go read the FAQ for hints on how to ask a question. Just dumping your entire code base here and expecting someone to do your job for you is just plain rude.
Sai Prasad anumolu 10-Aug-14 8:34am    
kk Thank you(No probelm) i need how retrive and update the image in outline sir ...

XML
<asp:TemplateField HeaderText="Photo">
                                            <ItemTemplate>
                                                <asp:Image ID="img_image" ImageUrl='<%# "~/News/"+Eval("ImagePath") %>' runat="server" Height="76px" Width="101px" />
                                            </ItemTemplate>
                                            <HeaderStyle HorizontalAlign="Left" />
                                        </asp:TemplateField>


u can check the Image url fied,there a name like News it is ur folder name. when u save ur image in folder,that image u can retrive on above code.
 
Share this answer
 
v2
Its would be not good to answer the question asked and answered so many times, again and again. Please see:
http://www.codeproject.com/search.aspx?q=C#+database+%28image+OR+images+OR+bitmap+OR+bitmaps%29&doctypeid=1;4;5[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900