⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 本文件包含200个visual baisc实例
💻 FRM
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form Form1 
   Caption         =   "将图片存入数据库(方法二)"
   ClientHeight    =   4140
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8010
   LinkTopic       =   "Form1"
   ScaleHeight     =   4140
   ScaleWidth      =   8010
   StartUpPosition =   3  '窗口缺省
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   405
      Left            =   1170
      Top             =   3615
      Width           =   4935
      _ExtentX        =   8705
      _ExtentY        =   714
      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         =   ""
      OLEDBString     =   ""
      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
   Begin VB.CommandButton Command3 
      Caption         =   "..."
      Height          =   345
      Left            =   2985
      TabIndex        =   4
      Top             =   45
      Width           =   570
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   0
      Top             =   345
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
      Filter          =   "*.*"
   End
   Begin VB.PictureBox Picture2 
      DataField       =   "图片"
      DataSource      =   "Adodc1"
      Height          =   3075
      Left            =   3750
      ScaleHeight     =   3015
      ScaleWidth      =   3990
      TabIndex        =   3
      Top             =   450
      Width           =   4050
   End
   Begin VB.PictureBox Picture1 
      Height          =   3090
      Left            =   75
      ScaleHeight     =   3030
      ScaleWidth      =   3390
      TabIndex        =   2
      Top             =   435
      Width           =   3450
   End
   Begin VB.CommandButton Command2 
      Caption         =   "退出"
      Height          =   330
      Left            =   7050
      TabIndex        =   1
      Top             =   3645
      Width           =   720
   End
   Begin VB.CommandButton Command1 
      Caption         =   "保存"
      Height          =   330
      Left            =   6255
      TabIndex        =   0
      Top             =   3645
      Width           =   720
   End
   Begin VB.Label Label3 
      BackStyle       =   0  'Transparent
      Caption         =   "查看数据"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   285
      Left            =   225
      TabIndex        =   7
      Top             =   3690
      Width           =   990
   End
   Begin VB.Label Label2 
      Caption         =   "保存在数据库的图片"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   300
      Left            =   3795
      TabIndex        =   6
      Top             =   120
      Width           =   2670
   End
   Begin VB.Line Line1 
      X1              =   3630
      X2              =   3630
      Y1              =   3585
      Y2              =   90
   End
   Begin VB.Label Label1 
      Caption         =   "打开要保存的文件:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   330
      Left            =   105
      TabIndex        =   5
      Top             =   75
      Width           =   2040
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim Cn As ADODb.Connection
Dim Rs As ADODb.Recordset
Dim mst As ADODb.stream
Dim mystr As String
Private Sub Form_Load()
  Adodc1.ConnectionString = "uid=admin;pwd=111;DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & App.Path & "\data.MDB"
  Adodc1.RecordSource = "data"
  Adodc1.Refresh
End Sub
Private Sub Command1_Click() '保存图片到数据库
  If mystr <> "" Then
     Set Cn = New ADODb.Connection
     Cn.ConnectionString = ";DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & App.Path & "\data.MDB"
     Cn.Open
     Set Rs = New ADODb.Recordset
     Rs.Open "select * from data", Cn, adOpenStatic, adLockOptimistic
     Set mst = New ADODb.stream
     mst.Type = adTypeBinary
     mst.Open
     mst.LoadFromFile mystr
     Rs.AddNew
     Rs.Fields("图片").Value = mst.Read
     Rs.Update
     Rs.Close
     Cn.Close
     Adodc1.Refresh
   Else
     MsgBox ("请先选择图片!")
  End If
End Sub
Private Sub Command3_Click()
  CommonDialog1.Filter = "bmp|*.jpg;*.bmp;*.gif"
  CommonDialog1.FilterIndex = 2
  ' 显示"打开"对话框
  CommonDialog1.ShowOpen
  Picture1.Picture = LoadPicture(CommonDialog1.FileName)
  mystr = CommonDialog1.FileName
End Sub
Private Sub Command2_Click()
  End
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -