Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 从数据库检索图像到listview。缩略视图_Mysql_Vb.net_Listview - Fatal编程技术网

Mysql 从数据库检索图像到listview。缩略视图

Mysql 从数据库检索图像到listview。缩略视图,mysql,vb.net,listview,Mysql,Vb.net,Listview,这是从特定文件夹检索图像并将其显示在列表视图中的代码。它以大图标显示图像,但我想从数据库中检索图像 代码如下: ListView1.Items.Clear() 'retrieve image from specific folder Dim dirFiles() As String = IO.Directory.GetFiles("D:\Capture") Dim _imgList As New ImageList Dim imgSize As New Si

这是从特定文件夹检索图像并将其显示在列表视图中的代码。它以大图标显示图像,但我想从数据库中检索图像

代码如下:

    ListView1.Items.Clear()
   'retrieve image from specific folder
    Dim dirFiles() As String = IO.Directory.GetFiles("D:\Capture")
    Dim _imgList As New ImageList
    Dim imgSize As New Size
   'setting up custom size
    imgSize.Width = 155
    imgSize.Height = 255
    ListView1.LargeImageList = _imgList
    ListView1.LargeImageList.ColorDepth = ColorDepth.Depth32Bit
    Dim count As Integer = 0
    Dim item As New ListViewItem
    For Each dirFile As String In dirFiles
        Dim imgFilename As String = IO.Path.GetFileNameWithoutExtension(dirFile)
        Dim img As New System.Drawing.Bitmap(dirFile)
        Dim imgImage As Image = Image.FromFile(dirFile)
        _imgList.ImageSize = imgSize
        _imgList.Images.Add(img.Clone)
        ListView1.Items.Add(imgFilename, count)
        count += 1
    Next

我尝试的教程不起作用,因为图像在保存到数据库之前会转换为字节数组,在我的工作中,我保存了图像的路径。有人能帮我吗?

你想做什么来保存图像或图像文件名?我用文件名保存图像路径,而不是图像本身。我已经可以保存图像路径了。我的问题是如何用上面的代码检索它,因为代码正在迭代文件夹中的文件。它不是使用从数据库读取的文件名。这就是我请求帮助的原因,代码显示了我的位置。