By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,238 Members | 1,804 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,238 IT Pros & Developers. It's quick & easy.

Store image in database with Visual C# 2K5 Express

P: n/a
Good day,

Im a beginner at C# and i use the book Visual C# 2005: How to program
from Deitel/Pearson.

I want to build a simple Anime (movie) database. It contains a list
box with all the anime titles and to the right are the corresponding
text fields like title, category, nr of episodes, etc.

If you switch from anime in the listbox the corresponding textfields
change also. This is done by the databinding settings in the property
section with a BindingSource1, AnimeDataSet1 etc. I did learn to save
the >text field< data by the following code:

private void button3_Click(object sender, EventArgs e)
{
bindingSource1.EndEdit();
animeTableAdapter1.Update(animeDataSet1.Anime);
}

This works fine.

Now I added a picturebox to the form, and set the databindings option
to the corresponding database field, named "pic".

Now this is how it works without saving the picture to the database:

I start the application. I select an anime in the ListBox. I select a
image by an OpenFileDialog button and I assign it to the picturebox.
When I change from anime titles in the ListBox, the picturebox changes
also but when I exit the program and start the program again the
images are gone!. This is all normal since i did not press the button
with the code:

private void button3_Click(object sender, EventArgs e)
{
bindingSource1.EndEdit();
animeTableAdapter1.Update(animeDataSet1.Anime);
}

When I DO press the button it dont save the picture in the
sqlDatabase. I use the inbuild sqldatabase that is provided by the
Visual C# program. As you have read I dont use myConnection or
SqlConnection Class because the databinding option in Visual C# does
it for you.

I hope you can help me,

Thnx in Advance.

Mar 27 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.