Click here to Skip to main content
15,886,691 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi friends, I am doing task display images from database in to image control using first next previous last buttons click events.successfully displayed images for first and last button click events.

But when I am click next and previous buttons the images could not be displayed.
Please find the solution here is my code..

Advance thanking you friends..


Dim rno As Integer
VB
Protected Sub btnprevious_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnprevious.Click
        cmd.CommandText = " select * from customerr"
        Dim da As New SqlDataAdapter
        Dim dt As New DataTable
        da.SelectCommand = cmd
        cmd.Connection = connection
        da.Fill(dt)
        rno = dt.Rows.Count - 1
        'If rno > 0 Then
        rno -= 1
        If dt.Rows.Count > "0" Then
            txtcustid.Text = dt.Rows(rno)(0).ToString()
            txtcustname.Text = dt.Rows(rno)(1).ToString()
            txtcustaddress.Text = dt.Rows(rno)(2).ToString()
            If dt.Rows(rno)(3) IsNot Nothing Then
                photo_aray = DirectCast(dt.Rows(rno)(3), Byte())
                photo_aray = dt.Rows(rno)(3)
                image1.ImageUrl = "data:image/png;base64," & Convert.ToBase64String(photo_aray)
            End If
        End If
        'End If

    End Sub





VB
Protected Sub btnxt_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnnxt.Click
        cmd.CommandText = "select * from customerr"
        Dim da As New SqlDataAdapter
        Dim dt As New DataTable
        da.SelectCommand = cmd
        cmd.Connection = connection
        da.Fill(dt)
        'Dim i As Integer
        'rno = dt.Rows.Count - 1
        If rno < dt.Rows.Count - 1 Then
            rno += 1
            If dt.Rows.Count > rno Then
                txtcustid.Text = dt.Rows(rno)(0).ToString()
                txtcustname.Text = dt.Rows(rno)(1).ToString()
                txtcustaddress.Text = dt.Rows(rno)(2).ToString()
                If dt.Rows(rno)(3) IsNot Nothing Then
                    photo_aray = DirectCast(dt.Rows(rno)(3), Byte())
                    photo_aray = dt.Rows(rno)(3)
                    image1.ImageUrl = "data:image/png;base64," & Convert.ToBase64String(photo_aray)
                End If
            End If
        End If
    End Sub
Posted
Updated 4-Sep-14 3:47am
v2

1 solution

why would you assign data of photo column to photo_array two times?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900