Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...If I'd only had resource like eng-tips when I was just getting started! I might have dazzled them with my brilliance instead of my BS..."

Geography

Where in the world do Tek-Tips members come from?
brews (TechnicalUser)
30 Apr 12 14:12
Using OpenFileDialog, a picture is loaded into a picbox and then saved to a db using only the picName not the path. When the record is subsequently called by these procedures an error message says that the pic could not be found and gives the path which is exactly where the pic is stored. The code and notes:

CODE

            If dataMgr.FindPix(intID, sImageFile) Then
                nMember.ClassPhoto = Replace(nMember.ClassPhoto, "''", "'")
                .imgClassPhoto.Load(nMember.ClassPhoto) 'error msg about path
                .btnChangePhoto.Text = "&Change Pho&to"
                btnChangePhoto.Font = New Font("arial", 8)
            Else
                .btnChangePhoto.Text = "Add Pho&to"
                btnChangePhoto.Font = New Font("arial", 8)
                .imgClassPhoto.Image = Nothing 'is this the code for having a blank picbox if no pic is in the db?
            End If

    Public Function FindPix(ByVal iID As Integer, ByRef sFile As String) As Boolean
        Dim dr As DataRow
        da = New OleDbDataAdapter
        ds = New DataSet
        da = New OleDbDataAdapter
        If cn.State = ConnectionState.Closed Then cn.Open()
        cmd = New OleDbCommand("SELECT MemberID, ClassPhoto FROM Members WHERE ClassPhoto ='" & sFile & "'", cn)
        da.SelectCommand = cmd
        da.Fill(ds, "Members")
        Try
            For Each dr In ds.Tables("Members").Rows
                With nMem
                    If .ClassPhoto = "" Then
                        cn.Close()
                        Return False
                    Else
                        sFile = .ClassPhoto
                    End If
                End With
                cn.Close()
                Return True
            Next dr
            cn.Close()
        Catch ex As Exception

        End Try
    End Function

Thank you.
brews (TechnicalUser)
30 Apr 12 15:54
The code was changed to this and now it works:

CODE

                sPath = Application.StartupPath & "\Photos"
                .imgClassPhoto.Load(sPath & "\" & nMember.ClassPhoto)

Thanks for the consideration. Any comments are always welcome.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close