.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

image updating in database

Posted By: Aamrapali Tamgadge     Posted Date: May 24, 2011    Points:5   Category :C#
hi. me having one image stored in sql server database table having the datatype image ,it is working properly when i insert the image but i want to update this image also showing the updated image on picturebox i have also convert this image to byte also byt it getting the error parameter is not valid.how can i solve it.here is my coding uder update button


SqlConnection con = new SqlConnection(@"Data Source=VISHU-A4E0E4F0F\sqlexpress;Initial Catalog=Toolbox;Integrated Security=True;Pooling=False");
SqlDataAdapter da;
DataTable dt = new DataTable();
ms = new MemoryStream();
pictureBox1.Image.Save(ms, ImageFormat.Jpeg);
byte[] data = new byte[ms.Length];
ms.Position = 0;
ms.Read(data, 0, Convert.ToInt32(ms.Length));

string str = "Update ImageData set Photo='" + data + "'";
da = new SqlDataAdapter(str, con);
da.Fill(dt);
MessageBox.Show("Data Updated Successfully");

Responses
Author: Pawan kumar Shukla             
Posted Date: May 25, 2011     Points: 20   

please provide the "where" clause in update query to which it has to update the image

like

string str = "Update ImageData set Photo='" + data + "'where image_id="+id ;

Author: Aamrapali Tamgadge             
Posted Date: May 25, 2011     Points: 20   

hi pawan i have update the image but i want to retrive this image on one get button by giving the perticular id
and i want to show this image on one picturebox how can show the database image on one picturebox which having the datatype image i have also convert it to byte also but still getting the parameter not valid error

Software Programmer At OTIS ISRC
Author: Aamrapali Tamgadge             
Posted Date: June 01, 2011     Points: 20   



Software Programmer At OTIS ISRC
Author: rashmi             
Posted Date: June 01, 2011     Points: 20   

put where clause in update query



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend