I have already accessed the data from the database and have displayed some of the info in text boxes but how do I display the image from the file path?
aspx:
<asp:Image ID="PlaceEventImage" runat="server" Height="120px" Width="217px" />
aspx.vb:
Dim placeName As String = CType(Session.Item("Place"), String)
Dim address1 As String = CType(Session.Item("Address1"), String)
Dim countyID As Integer = CType(Session.Item("CountyID"), Integer)
Dim aConnection4 As New OleDbConnection
Dim aDataAdapter5 As OleDbDataAdapter
Dim ds1 As New DataSet
Dim aCommand5 As OleDbCommand
Dim Sql5 As String
aConnection4.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("App_Data/MyLocalWebsite.mdb")
Sql5 = "SELECT PlaceName, Address1, Address2, PlaceData.CountyID, PlaceCategoryID, Image, CountyData.CountyID, County FROM PlaceData INNER JOIN CountyData ON (CountyData.CountyID = PlaceData.CountyID) WHERE PlaceName = '" & placeName & "' AND Address1 = '" & address1 & "' ORDER BY PlaceName"
aCommand5 = New OleDbCommand(Sql5, aConnection4)
aConnection4.Open()
aDataAdapter5 = New OleDbDataAdapter(Sql5, aConnection4)
aDataAdapter5.Fill(ds1, "PlaceInfo")
aConnection4.Close()
Dim imageUrl As String = ds1.Tables("PlaceInfo").Rows(0).Item(5)
PlaceEventName.Text = ds1.Tables("PlaceInfo").Rows(0).Item(0)
Address1Label.Text = ds1.Tables("PlaceInfo").Rows(0).Item(1)
Address2Label.Text = ds1.Tables("PlaceInfo").Rows(0).Item(2)
CountyLabel.Text = ds1.Tables("PlaceInfo").Rows(0).Item(7)
Eventually got it working, below is solution that worked. Image got saved to the database as full file path but the image was uploaded to the server so needed to change the path to the server:
Dim imageUrl As String = ds1.Tables("PlaceInfo").Rows(0).Item(5)
Dim found As Integer = imageUrl.LastIndexOf("\")
Dim filename As String = imageUrl.Substring(found)
Dim newFilename As String = filename.Replace("\", "/")
PlaceEventImage.ImageUrl = "~/Uploads" + newFilename