用VB6读写数据库中的图片

页面导航:首页 > 软件编程 > vb.net > 用VB6读写数据库中的图片

用VB6读写数据库中的图片

来源: 作者: 时间:2016-02-05 12:32 【

1,以人名和相关图片为例说明,数据库为Access,有如下字段:Name char,picture OLE object,FileLength Number。当为ms sql时,将picture改为lob即可。 2,

 

 

   1,以人名和相关图片为例说明,数据库为Access,有如下字段:Name char,picture OLE object,FileLength

Number。当为ms sql时,将picture改为lob即可。

   2,示例包含control:commom dialog,picture,listbox。

如下:

Option Explicit

 

Private Declare Function GetTempFileName Lib "kernel32" Alias "GetTempFileNameA" (ByVal lpszPath As

String, ByVal lpPrefixString As String, ByVal wUnique As Long, ByVal lpTempFileName As String) As Long

Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long,

ByVal lpBuffer As String) As Long

Private Const MAX_PATH = 260

 

Private m_DBConn As ADODB.Connection

 

Private Const BLOCK_SIZE = 10000

注释: Return a temporary file name.

Private Function TemporaryFileName() As String

Dim temp_path As String

Dim temp_file As String

Dim length As Long

 

    注释: Get the temporary file path.

    temp_path = Space$(MAX_PATH)

    length = GetTempPath(MAX_PATH, temp_path)

    temp_path = Left$(temp_path, length)

 

    注释: Get the file name.

    temp_file = Space$(MAX_PATH)

    GetTempFileName temp_path, "per", 0, temp_file

    TemporaryFileName = Left$(temp_file, InStr(temp_file, Chr$(0)) - 1)

End Function

Private Sub Form_Load()

Dim db_file As String

Dim rs As ADODB.Recordset

 

    注释: Get the database file name.

    db_file = App.Path

    If Right$(db_file, 1) <> "" Then db_file = db_file & ""

    db_file = db_file & "dbpict.mdb"

 

    注释: Open the database connection.

    Set m_DBConn = New ADODB.Connection

    m_DBConn.Open _

        "Provider=Microsoft.Jet.OLEDB.4.0;" & _

        "Data Source=" & db_file & ";" & _

        "Persist Security Info=False"

Tags:

相关文章

    文章评论

    最 近 更 新
    热 点 排 行
    Js与CSS工具
    代码转换工具
    
    <