Hi guys! i wonder how can i save image path in a string to MySQL, i mean...what instruction i have to use...i want to save it to MySQL and then show it into a picture box. Thank you very much for your help.

Recommended Answers

All 14 Replies

Hi,
Get the path using opendialog control, then save the path to database.
When you want to show it, just load from database and show it using picture box.
Just it.

Sorry to bother you, but can you be more expecific? using and example please?

okay..
post your save code and load code..
i'll fix it with open dialog code.

okay..
post your save code and load code..
i'll fix it with open dialog code.

ok, i have this code:

If Text1 = KeyPress Then
Label = CommonDialog1.FileName
End If

but i have an error with KeyPress event :C

ok, i have this code:

If Text1 = KeyPress Then
Label = CommonDialog1.FileName
End If

but i have an error with KeyPress event :C

This not a code i asking for..
I asked your code for save or load data from database.
or you didn't have a code for save or load data?
and for your code how you can assign a textbox with keypress ? and you try to get file name without select it.

the code to save data is this:

With Adodc1
.Recordset.Save 'lo que tiene la tabla se va a guardarn
MsgBox "Los datos han sido guardados", vbInformation, "aviso"
.Refresh 'actulizar
.Recordset.Requery
End With

See if this help.
This following example code is how to save image path into mysql:

Button Browse used to select an image and show the path to lblPath.

Private Sub btnBrowse_Click()
CommonDialog1.Filter = "All files (*.*)|*.*"
CommonDialog1.DialogTitle = "Select File"
CommonDialog1.ShowOpen

lblPath.Caption = CommonDialog1.FileName ' label path to show path of image
End Sub

Button Save used to store data into database.

Private Sub btnSave_Click()
With Adodc1
    .Refresh
    .Recordset.AddNew
    .Recordset.Fields("IdAddress") = txtIdAddress.Text
    .Recordset.Fields("First_Name") = txtFirstName.Text
    .Recordset.Fields("Last_Name") = txtLastName.Text
    .Recordset.Fields("Phone_Num") = txtPhoneNumber.Text
    .Recordset.Fields("Email") = txtEmail.Text
    .Recordset.Fields("PhotoPath") = lblPath.Caption ' This field will save path of selected image from common dialog.
    .Recordset.Update
End With
    MsgBox "Data Added"
End Sub

try it and let see how it works..

Thank you very much for your help n.n
Do have any idea of how can i refresh the image when i pulse the botton new? this is the code i have:

With Adodc1
.CommandType = adCmdTable
.RecordSource = "exp" 'table's name
.Refresh
.Recordset.AddNew 'representa el nuevo dato a guardar
End With

the grid is refresh, but not the same with the image
Thanks a lot

Thanks a lot

Try this :

Set Picture1.Picture = Nothing

Don't forget to mark this thread as solved :)

It works!! thank you very much for your help :)

So this thread is solved n_n

Your're Welcome..
Please Mark your thread as solved..
you can find the link below the posts.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.