i have created a page were by using file upload i have uploaded pdf,doc files to a folder inside the project file path saved in database table.but the problem is by using list view i retrieve data in another page from that same database table,but how can i access that file to read in pdf or doc by using file path which stored in database table. Actually i don't know how to display it. Here is the code of list view i used.Please anybody help me am new student in this field.

Partial Class AdminCareer
    Inherits System.Web.UI.Page
    Dim cn As New SqlConnection(ConfigurationManager.ConnectionStrings("MyConnection").ConnectionString)
    Dim cmnd As New SqlCommand, cmnd1 As New SqlCommand
    Dim sdr As SqlDataReader
    Dim drPdf As OleDb.OleDbDataReader
    Dim cmd1 As OleDb.OleDbCommand
    Dim ob As New Careeradd


    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        If chk_data() > 0 Then
            Lblmes.Visible = False
            SqlDataSource1.SelectCommand = "SELECT [Fname], [Lname], [Nationality], [Phone], [Email], [Exeperince], [Position], [Date] FROM [Career] ORDER BY [RefNo]"
            SqlDataSource1.DataBind()

        Else
            Lblmes.Visible = True
        End If


    End Sub
    Protected Sub ListView1_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewCommandEventArgs) Handles ListView1.ItemCommand
        Dim lnkb As New LinkButton
        lnkb = e.CommandSource
        Dim lbl1 As New Label
        lbl1 = CType(e.Item.FindControl("lblRefno"), Label)

        'Dim pdf As String = ("SELECT * FROM Career where refno='" & lbl1.Text & "'")
        'cn.Open()
        'cmd1 = New OleDb.OleDbCommand(pdf, cn)
        'drPdf = cmd1.ExecuteReader
        'If drPdf.Read = True Then
        '    Dim fpath As String = drPdf("fileurl")
        '    Dim MyDirectoryPath As String = System.IO.Path.GetDirectoryName(fpath)
        'End If
        '' Dim fname As String = Path.GetFileName(fpath)
        If lnkb.ID = "Lnkdelete" Then
            Dim s As String = "delete from Career where refno=" & lbl1.Text
            cn.Open()
            cmnd = New SqlCommand(s, cn)
            cmnd.ExecuteNonQuery()
            cn.Close()
        End If



    End Sub
    Public Function chk_data() As Integer
        Dim cc As Integer
        Dim s As String = "SELECT [Fname], [Lname], [Nationality], [Phone], [Email], [Exeperince], [Position], [Date] FROM [Career] ORDER BY [RefNo]"
        cn.Open()
        cmnd = New SqlCommand(s, cn)
        sdr = cmnd.ExecuteReader()
        While (sdr.Read())
            cc = Val(sdr.GetValue(0))
        End While
        cn.Close()
        Return cc
    End Function
End Class

Related posts

Recent Viewed