views:

47

answers:

1

I am using vb.net running a backend MS.Access database and I am wondering what is the code that I can use to display a picture of an image when the field name is selected.

My MS Access "field" name is Cars_Types: in the files I have the data "GM, Chrysler, Toyota, Honda, and Ford".

The name of my database is ModelCars.accdb

The pictures are not coded into the database instead I would like them to be coded into the VB.NET program.

I have the database working correctly within my VB.NET program but I am having trouble getting the images to appear.

A: 

If you just have the five images or so, you could store them in your .NET application as local resources. When you retrieve an associated record from the database, display it (in whatever context you need, I copied the msdn example here):

Me.Background= My.Resources.GMImage

Edit: To select which image to use, if you have a string in the DB of the various car types, just use a switch statement:

Select Case(carType)
    Case "GM": me.picCarPhotos = My.Resources.GMImage
    Case "Ford": me.picCarPhotos = My.Resources.FordImage
End Select

Disclaimer: I'm more familiar with C# so this may need some tweaking if my VB is off.

JYelton
Okay, I think I have it, for me since I have already created the picture box on my form it would be this way.me.picCarPhotos = My.Resources.GMImage.But how do you call the field "Car_Type" Data "Ford" to match the image in my recources bin FordFocus.jpg
Michael
The easiest way that I can think of would just be to use a switch statement. I'll edit the answer with that code.
JYelton