当前位置:编程学习 > VB >>

vb2005中,如何将大型文件以二进制流的形式存入access数据库中,我需要详细的操作过程和代码,谢谢

vb2005中,如何将大型文件(如PPT文件)以二进制流的形式存入access数据库中,我需要详细的操作过程和代码,谢谢! --------------------编程问答-------------------- Imports System.Data.OleDb
Imports System.IO



    Dim OperateFile As System.IO.FileStream

Private Sub InsertFile(ByVal First_ID As Integer, ByVal ConnStr As String)
        Dim OpenFile As New OpenFileDialog
        If OpenFile.ShowDialog = Windows.Forms.DialogResult.OK Then
            Try
                OperateFile = New IO.FileStream(OpenFile.FileName, IO.FileMode.Open, IO.FileAccess.Read)
                Dim FileA(OperateFile.Length - 1) As Byte
                OperateFile.Read(FileA, 0, OperateFile.Length - 1)
                Dim conn As New OleDbConnection(ConnStr)
                Dim strComm As String = " INSERT INTO SaveFile(FirstID,FileData,FileName) VALUES('" & First_ID & "', @photoBinary ,'" & OpenFile.SafeFileName & "')"
                '修改连接语句
                Dim myComm As OleDb.OleDbCommand = New OleDbCommand(strComm, conn)
                myComm.Parameters.Add("@photoBinary", OleDbType.Binary, FileA.Length)
                myComm.Parameters("@photoBinary").Value = FileA
                conn.Open()
                myComm.ExecuteNonQuery()
                conn.Close()
                MsgBox("添加成功")
            Catch ex As Exception
                MessageBox.Show(ex.ToString)
            End Try

        End If
    End Sub

补充:VB ,  数据库(包含打印,安装,报表)
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,