使用vb.net下一个上一个按钮显示数据库中的图像 [英] Display images from database using vb.net next previous buttons

查看:68
本文介绍了使用vb.net下一个上一个按钮显示数据库中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,我正在执行任务显示图像从数据库到图像控制使用第一个下一个上一个最后一个按钮点击events.successfully显示图像的第一个和最后一个按钮点击事件。



但是当我点击下一个和上一个按钮时,图像无法显示。

请在这里找到解决方案是我的代码..



预先感谢你的朋友..





Dim rno As Integer

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

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
















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

推荐答案

为什么要将photo-column的数据分配给photo_array两次?
why would you assign data of photo column to photo_array two times?


这篇关于使用vb.net下一个上一个按钮显示数据库中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆