BP Forums
NEED YOUR HELP PLEASE.. - Printable Version

+- BP Forums (https://bpforums.info)
+-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55)
+--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56)
+---- Forum: VB.NET (Visual Basic 2010/2008) (https://bpforums.info/forumdisplay.php?fid=8)
+----- Forum: Programming Help (https://bpforums.info/forumdisplay.php?fid=9)
+----- Thread: NEED YOUR HELP PLEASE.. (/showthread.php?tid=598)

Pages: 1 2


NEED YOUR HELP PLEASE.. - jochen29 - 08-11-2012

i'm having problem with my program.. its like directory for the students i want to include picture in the student info.. but i dont know how to do that.. is there any way i can do that? please i really need your help for these.. any help will do.. <!-- sCry --><img src="{SMILIES_PATH}/icon_cry.gif" alt="Cry" title="Crying or Very Sad" /><!-- sCry -->


Re: NEED YOUR HELP PLEASE.. - Vinwarez - 08-11-2012

Can you be more specific? I don't understand what do you mean.


Re: NEED YOUR HELP PLEASE.. - brandonio21 - 08-11-2012

I don't really know what you mean either. To display a picture in your program, you're going to want to use the PictureBox control, but that's all the help that I can really give you with the information that you provided.


Re: NEED YOUR HELP PLEASE.. - jochen29 - 08-11-2012

oh.. im sorry.. lets say i have a database table name student_info. one of the fields i created is the imagepath.. i want to save the path of the image in that field.. and after saving that if i want to view the student info in my program..the student info appears and so as the image.. how can i do that?


Re: NEED YOUR HELP PLEASE.. - Vinwarez - 08-11-2012

I'm going to sleep right now, meaning I don't have time to help, at the moment. If Brandon doesn't help you in a few hours, when I wake up I will.

Right now, it is like 0:50 am here, so yeah. I usually wake up at 08:00/08:30(am).



Re: NEED YOUR HELP PLEASE.. - jochen29 - 08-11-2012

jochen29 Wrote:oh.. im sorry.. lets say i have a database table name student_info. one of the fields i created is the imagepath.. i want to save the path of the image in that field.. and after saving that if i want to view the student info in my program..the student info appears and so as the image.. how can i do that?

here if this would help you understand..


[Image: 4604f0fa.png]


Re: NEED YOUR HELP PLEASE.. - Vinwarez - 08-11-2012

What you could do is use this code when you click buttons for scrolling (Next, Previous, First, Last):
[code2=vbnet]Try
PictureBox1.Image = Image.FromFile(ImageTextBox.Text)
Catch ex As Exception
MsgBox(ex.Message) ' Style your message box a bit, if you want.
End Try[/code2]
When an user clicks the upload button, add this code:
[code2=vbnet]Dim OpenImage As New OpenFileDialog
OpenImage.Title = "Upload your image"
OpenImage.InitialDirectory = "C:\"
OpenImage.Filter = "Images Files|*.jpg;*.png;*.jpeg;*.bmp"
Dim x = OpenImage.ShowDialog()

If x = DialogResult.OK Then
Try
PictureBox1.Image = Image.FromFile(OpenImage.FileName)
ImageTextBox.Text = OpenImage.FileName
Catch ex As Exception
MsgBox(ex.Message) ' Style your message box a bit, if you want.
End Try
End If[/code2]

That is basically it. That's everything you need in order to display an image. If you want to display .GIF images, you need to use StreamWriter, otherwise it will say "Out of Memory". When the form loads, it doesn't matter which file extension the image have, it will show "Out of Memory", so don't add it there. Everything else works like a charm. If this didn't help you totally, it at least gave you some kind of idea how would it work.


Re: NEED YOUR HELP PLEASE.. - jochen29 - 08-11-2012

so how can i save it to the database then? what i want to save is the image path and then.. when i want to scroll it and show it to the picture box how can i call it from the database..to show the image of the particular person? lets say i run the program here must be the output..


[Image: c9db343c.png]


and what if i want to create a folder inside the program folder to put the images there?


Re: NEED YOUR HELP PLEASE.. - Vinwarez - 08-12-2012

Are you using MySQL database or Service-Based (in VB/VS) database?


Re: NEED YOUR HELP PLEASE.. - jochen29 - 08-12-2012

yea i'm using MySQL database..


Re: NEED YOUR HELP PLEASE.. - Vinwarez - 08-12-2012

I cannot help you then. I've never used MySQL databases. Brandon will help you when he logs on.

Basically what you want to do is, retrieve a value from the path column and then set PictureBox's image to it.


Re: NEED YOUR HELP PLEASE.. - jochen29 - 08-12-2012

oh.. <!-- sCry --><img src="{SMILIES_PATH}/icon_cry.gif" alt="Cry" title="Crying or Very Sad" /><!-- sCry --> i see.. thanks for the help though.. maybe i should wait for brandonio to help me.. thanks man.

yea your right that's what i want to do.. but i don't know how to do that.. that's why i need anyone's help.. and i'm also new to VB.net


Re: NEED YOUR HELP PLEASE.. - brandonio21 - 08-12-2012

Thanks for helping Vinwarez!

Anyway, there is a very basic premise to what you are trying to do. Basically, user chooses image, image gets uploaded, URL of that image gets saved in the database.

So, for example, if you specify a local image for the student "John Smith", the image might get renamed as "johnsmith81212.jpg" and then uploaded via FTP to the url "site.com/images/johnsmith81212.jpg". Then, the MySQL image field for "John Smith" is updated to "johnsmith81212.jpg". Then, when retrieving the image, the program reads the MySQL field, downloads the image, and displays it into the PictureBox.

This may not be the best way of doing it, but it is how I did it in a huge piece of software for a client and it seemed to get the job done.


Re: NEED YOUR HELP PLEASE.. - jochen29 - 08-12-2012

no.. what if the images i uploaded is on the local folder only..? like inside the image folder i created inside the debug folder? how can i save the image path to the database and retrieve it to the database to show it in picture box? so how am i gonna do that? can you show me some example please to better understand?


Re: NEED YOUR HELP PLEASE.. - brandonio21 - 08-12-2012

If they are on the local folder only, then simply save a MySQL Field containing the file name for each student, then load that picture!


Re: NEED YOUR HELP PLEASE.. - jochen29 - 08-13-2012

that's my problem <!-- sCry --><img src="{SMILIES_PATH}/icon_cry.gif" alt="Cry" title="Crying or Very Sad" /><!-- sCry --> i don't know how to code that.. <!-- s:oops: --><img src="{SMILIES_PATH}/icon_redface.gif" alt=":oops:" title="Embarrassed" /><!-- s:oops: -->
maybe if you could demonstrate a tutorial to do that.. i appreciate it very much..


Re: NEED YOUR HELP PLEASE.. - jochen29 - 08-13-2012

i need it so badly.. <!-- sCry --><img src="{SMILIES_PATH}/icon_cry.gif" alt="Cry" title="Crying or Very Sad" /><!-- sCry -->


Re: NEED YOUR HELP PLEASE.. - brandonio21 - 08-13-2012

Which part do you need help coding? The MySQL part? The reading pictures from a file part?


Re: NEED YOUR HELP PLEASE.. - jochen29 - 08-14-2012

reading pictures from a file path..


Re: NEED YOUR HELP PLEASE.. - brandonio21 - 08-14-2012

Ah, well this should help you out! This code loads a picture from the filesystem and loads it into a picturebox!

[code2=vbnet]Dim picture As Image = _
Image.FromFile(My.Application.Info.DirectoryPath & "/images/picture.png")
PictureBox1.Image = picture[/code2]