Click here to Skip to main content
15,918,742 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Sir
I have using window form application
and save data in ms-access
when i load picturebox in photo
then i found Error: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. and try catch also not work


code is this
C#
try
{
opd_photo = new OpenFileDialog(); 
opd_photo.FileName = null;
opd_photo.Filter = "Image Files(*.png; *.jpg; *.bmp)|*.png; *.jpg; *.bmp";
if (opd_photo.ShowDialog() == DialogResult.OK) -------- //HERE I GET ERROR
{
pcb_photo.ImageLocation = opd_photo.FileName;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}


Please help me.
Posted
Updated 12-Jul-12 22:55pm
v3

1 solution

It's difficult if not impossible to be accurate about these things, but I would say that you are trying to open an invalid video file, and the preview is throwing an error. Certainly, when I try with your code I get no such problem. Have you tried looking at different images?

BTW: You may find this worth looking at - A FileDialog.Filter generator for all supported images[^]
It supplies a filter string which matches all image formats known to your current system.


"hello sir
i am save in database image loction and save in folder.
This is an access database if we take sql database then it not show any error and working fine"


Then the problem is in one of three places:
1) It's the code you use to load and then save the image to the DB.
2) It's the datatype of the field you are using to store the image in the DB.
3) It's the code you are using to read the image from the DB and save it to disk.

At this point, I can't tell - I need the relevant code fragments and the database field definition.
But the file you have written is invalid, and the preview is throwing an error.
 
Share this answer
 
v2
Comments
kuldeepkumartak 13-Jul-12 4:52am    
hello sir
i am save in database image loction and save in folder.
This is an access database if we take sql database then it not show any error and working fine
OriginalGriff 13-Jul-12 5:03am    
Answer updated

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