Hello All,

I have stored a Image in my sql server database and when i am tring to retrive the data the following error is coming..
(Conversion from string " 8901.jpg " to type 'Boolean' is not valid.)
In the database and also in the \\Debug\member file that .jpeg files are showing.. still i am getting the error.

I saw all the threads regarding Image retriving but it could not help me..

table name = employeeDtls
Field -- A_IMG nvarchar(10)

My code Is..

Public Sub ASSING(ByVal k As String)
str = Application.StartupPath & "\members\"
conn = GetConnect()
conn.Open()
Dim cmd As New SqlCommand("select * from EmployeeDtls where StaffNo='" & k & "'", conn)
Dim dr As SqlDataReader
dr = cmd.ExecuteReader

If dr.Read Then

If IsDBNull(dr.Item("A_IMG")) Then
Picimage.Image = Nothing
Else
k = dr.Item("A_IMG")
Picimage.Image = Image.FromFile(str, k)
End If
End If
conn.Close()

Image.FromFile(str, k) is in error.
FromFile only takes one parameter for the filename.
The second parameter is a boolean for useEmbeddedColorManagement.
Try Image.FromFile(System.IO.Path.Combine(str, k))

Thanks Nick for your suggestion , ihave tried but one error is coming

(FileNotFoundException was Unhandeled by User Code)

Can u please help me on this ..Or if u have any example regarding "image saving and retriving "then please send the example" or shall i send my code then u can able to identify where the problem is..

I was tring this from last 3/4 days but i dont know in a pirticular point (From File)it is showing error..

Please help me..

FileNotFoundException says everything
do:
Debug.Writeline(System.IO.Path.Combine(str, k)) and check what the path is and compare it to the one you expected. im sure they are different

The image is most likely stored as a byte stream in the database.
You have to read the image from the database into a byte array.
From there, you can read the byte array into a memory stream, which in turn is used to call: Image.FromStream(.....)

commented: If you check the code this is clearly not the case! +0

The image is most likely stored as a byte stream in the database.
You have to read the image from the database into a byte array.
From there, you can read the byte array into a memory stream, which in turn is used to call: Image.FromStream(.....)

If you look at the code the file is clearly on disk and the DB contains the filename Field -- A_IMG nvarchar(10) .
The problem, as GeekByChoiCe said, is with getting the correct path and filename!

Thank You all..

Yes problem was in the path only...

Problem SOlved..........THANK YOU

Glad to help. If solved please mark solved.

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.