hello guys..

Can someone give me a code on storing path image and retrieve path into image using mysql database and vb.net/vs 2008. I only know how to make a browse button and get the image into hard disk and display it in picturebox. I'm done with the the problem is how to store the path and retrieve the path into image..please

Pre-requisites:
Have the MySql Conector installed and referenced in your project.
Have a MySql database (MyBase) with a table (MyTable) having an Id integer field to reference the record and a FullPath string to hold the full absolute path to the image file.

Assumptions:
You already know the image Id to insert/search for (IE: 3) and the path is in the FullPath field

Actions:
To Retreive the Path from the DB:
Open a new connection to the MySql Database
Create a new Command to: SELECT FullPath FROM Mytable WHERE Id = 3
Create a Reader using the Command.ExecuteReader agains the connection
If the Reader has rows andalso Reader.Read is true then ResultingFullPath (as string) should be obtained from Reader.GetString(0)
Remenber to close the reader and the connection.

To Save the path to the database:
Open a new connection to the MySql Database
Create a new Command to :INSERT INTO Mytable VALUES ( 3, '\\Server\Share\Folder\File.jpg')
Execute the non query command against the connection. Should return 1 as the nuber of affected records.
Remenber to close the connection.

Remember to use try / catch blocks in the execution of the commands to intercetp and got knowledge of any error from the database.

Hope this helps

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.