?? form1.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 + -