【问题标题】:MS Access import image into tableMS Access 将图像导入表格
【发布时间】:2016-01-16 10:43:13
【问题描述】:

在 MS Access 中,我希望能够在系统上搜索一个或多个图像,然后将它们保存到链接到 SQL 服务器的表中的 OLE 字段中。

在表单中进行预览也是理想的。

这似乎是一项简单的任务,但老实说,经过数小时的搜索,我已经放弃了。 由于我将图像作为 Varbinary(MAX) 存储在 SQL 数据库中,所以没有我不想只存储图像的链接。

【问题讨论】:

    标签: sql-server database image ms-access ole


    【解决方案1】:

    设置图像字段后,我将其附加到按钮上:

    Private Sub CommandOpenPicture_Click()
         Dim strFilter As String
         Dim strInputFileName As String
    
         strFilter = ahtAddFilterItem(strFilter, "JPEG Files (*.jpg, *.jpeg)", "*.jpg;*.jpeg")
         strFilter = ahtAddFilterItem(strFilter, "bmp Files (*.bmp)", "*.bmp")
         strFilter = ahtAddFilterItem(strFilter, "all Files (*.*)", "*.*")
    
         strInputFileName = ahtCommonFileOpenSave( _
                                 Filter:=strFilter, _
                                 OpenFile:=True, _
                                 DialogTitle:="Choose an image file...", _
                                 Flags:=ahtOFN_HIDEREADONLY)
    
         If Len(strInputFileName) > 0 Then
             ' Do something with the selected file
            imgDamPic.Picture = strInputFileName
            Me.DamsPhoto.Value = imgDamPic.Picture
            file_path.Value = strInputFileName
                    'Put SQL Insert Statement or DAO here
    
          Else
             'No file chosen, or user canceled
          End If
    End Sub
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多