TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Nel
NA
716
1.1m
How to insert picture in access database from C# form
Feb 1 2012 3:54 AM
Hi,
I have an access database with one field of type OLE Object. I want to insert a picture and I have this code:
byte[] imageData = ReadFile(textBox15.Text);
com.Parameters.AddWithValue("@Slikadog", imageData);
byte[] ReadFile(string sPath)
{
byte[] data = null;
FileInfo fInfo = new FileInfo(sPath);
long numBytes = fInfo.Length;
FileStream fStream = new FileStream(sPath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fStream);
data = br.ReadBytes((int)numBytes);
return data;
}
void GetImagesFromDatabase()
{
try
{
OleDbDataAdapter ADAP = new OleDbDataAdapter("Select Slikadog from Dogovor", conn);
DataSet DS = new DataSet();
ADAP.Fill(DS, "Dogovor");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
but when I run the application, in the database Ole Object field (the image field) I get only "Long binary data"
I don't know whether this is the right way to insert picture from a file. Please help me.
Thank you in advance.
Reply
Answers (
4
)
How to plot graph in picturebox or any 3rd party plug-in with data from Excel, using C#
How to make administrator class to control menu