VERSION 5.00 Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX" Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX" Begin VB.Form Form1 Caption = "Form1" ClientHeight = 5445 ClientLeft = 60 ClientTop = 345 ClientWidth = 8790 LinkTopic = "Form1" ScaleHeight = 5445 ScaleWidth = 8790 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command3 Caption = "Command3" Height = 495 Left = 0 TabIndex = 3 Top = 1560 Width = 1215 End Begin VB.PictureBox Picture1 Height = 4935 Left = 2880 ScaleHeight = 4875 ScaleWidth = 5355 TabIndex = 2 Top = 240 Width = 5415 End Begin VB.CommandButton Command2 Caption = "Command2" Height = 495 Left = 1320 TabIndex = 1 Top = 0 Width = 1215 End Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 0 TabIndex = 0 Top = 0 Width = 1215 End Begin MSComDlg.CommonDialog CommonDialog1 Left = 1800 Top = 840 _ExtentX = 847 _ExtentY = 847 _Version = 393216 End Begin MSAdodcLib.Adodc Adodc1 Height = 735 Left = 0 Top = 720 Width = 1575 _ExtentX = 2778 _ExtentY = 1296 ConnectMode = 0 CursorLocation = 3 IsolationLevel = -1 ConnectionTimeout= 15 CommandTimeout = 30 CursorType = 3 LockType = 3 CommandType = 8 CursorOptions = 0 CacheSize = 50 MaxRecords = 0 BOFAction = 0 EOFAction = 0 ConnectStringType= 1 Appearance = 1 BackColor = -2147483643 ForeColor = -2147483640 Orientation = 0 Enabled = -1 Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\VB6\test1\PictureToDatabase\temp1.mdb;Persist Security Info=False" OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\VB6\test1\PictureToDatabase\temp1.mdb;Persist Security Info=False" OLEDBFile = "" DataSourceName = "" OtherAttributes = "" UserName = "" Password = "" RecordSource = "" Caption = "Adodc1" BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} Name = "宋体" Size = 9 Charset = 134 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty _Version = 393216 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Dim rs1 As New ADODB.Recordset Dim mst As New ADODB.Stream Dim strACE As String Dim photoFileName As String Dim strsql As String Private Sub Command1_Click() ' With Me.CommonDialog1 .InitDir = App.Path .Filter = "Jpg(*.jpg)|*.jpg|Jpeg(*.jpeg)|*.jpeg" .DefaultExt = ".jpg" .ShowOpen photoFileName = .FileName Me.Picture1.Picture = LoadPicture(photoFileName) End With Debug.Print photoFileName End Sub Private Sub Command2_Click() ' strsql = "SELECT 表1.编号,表1.name,表1.file FROM 表1; " Me.Adodc1.RecordSource = strsql Me.Adodc1.Refresh mst.Type = adTypeBinary mst.Open If photoFileName <> "" Then mst.LoadFromFile (photoFileName) End If Me.Adodc1.Recordset.AddNew Me.Adodc1.Recordset.Fields(1) = photoFileName Me.Adodc1.Recordset.Fields(2) = mst.Read Me.Adodc1.Recordset.Update Me.Adodc1.Recordset.Close mst.Close End Sub 'SELECT 表1.编号,表1.file FROM 表1; Private Sub Command3_Click() ' strsql = "SELECT 表1.编号,表1.file From 表1 WHERE (((表1.编号)=2)); " Me.Adodc1.RecordSource = strsql Me.Adodc1.Refresh Set Me.Picture1.DataSource = Me.Adodc1 Me.Picture1.DataField = "file" End Sub 'SELECT 表1.编号,表1.file From 表1 WHERE (((表1.编号)=2)); Private Sub Form_Load() ' strACE = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\VB6\test1\PictureToDatabase\temp1.mdb;Persist Security Info=False" Me.Adodc1.ConnectionString = strACE End Sub 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\VB6\test1\PictureToDatabase\temp1.mdb;Persist Security Info=False