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:
Thank you.
Code:
If dataMgr.FindPix(intID, sImageFile) Then
nMember.ClassPhoto = Replace(nMember.ClassPhoto, "''", "'")
.imgClassPhoto.Load(nMember.ClassPhoto) [COLOR=red]'error msg about path[/color red]
.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 [COLOR=red]'is this the code for having a blank picbox if no pic is in the db?[/color red]
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.