📄 form1.frm
字号:
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 = 8790
ClientLeft = 60
ClientTop = 345
ClientWidth = 12270
LinkTopic = "Form1"
ScaleHeight = 8790
ScaleWidth = 12270
StartUpPosition = 3 '窗口缺省
Begin MSComDlg.CommonDialog CommonDialog1
Left = 630
Top = 1935
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.TextBox Text1
DataField = "id"
DataSource = "Adodc1"
Height = 330
Left = 225
TabIndex = 3
Text = "Text1"
Top = 495
Width = 1140
End
Begin VB.CommandButton Command2
Caption = "增加"
Height = 510
Left = 225
TabIndex = 2
Top = 3330
Width = 915
End
Begin VB.CommandButton Command1
Caption = "修改"
Height = 420
Left = 225
TabIndex = 1
Top = 2745
Width = 915
End
Begin MSAdodcLib.Adodc Adodc1
Height = 330
Left = 90
Top = 4140
Width = 1650
_ExtentX = 2910
_ExtentY = 582
ConnectMode = 3
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 2
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:\VB+Access数据库创建和应用\test\db1.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\VB+Access数据库创建和应用\test\db1.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "表1"
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.PictureBox Picture1
AutoRedraw = -1 'True
AutoSize = -1 'True
DataField = "photo"
DataSource = "Adodc1"
Height = 4740
Left = 1980
ScaleHeight = 4680
ScaleWidth = 4680
TabIndex = 0
Top = 90
Width = 4740
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Private Sub Adodc1_Error(ByVal ErrorNumber As Long, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, fCancelDisplay As Boolean)
'fCancelDisplay = False
'End Sub
'
'Private Sub Adodc1_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
'On Error Resume Next
'Me.Adodc1.Caption = pRecordset.Fields("id")
'End Sub
Private Sub Command1_Click()
Dim ps
Dim c As ADODB.Stream
With Me.CommonDialog1
.DialogTitle = "输入图片"
.CancelError = True
.Filter = "图片文件(*.bmp;*.gif;*.jpg)|*.bmp;*.gif;*.jpg"
On Error GoTo lin
.ShowOpen
If Len(.FileName) = 0 Then
Exit Sub
End If
ps = .FileName
.FileName = ""
End With
Set c = New ADODB.Stream
c.Mode = adModeReadWrite
c.Type = adTypeBinary
c.Open
c.LoadFromFile ps
Me.Adodc1.Recordset.Fields("photo").Value = c.Read
Picture1.Picture = LoadPicture(ps)
c.Close
Exit Sub
lin:
If Err.Number <> 32755 Then
MsgBox Err.Description
End If
End Sub
Private Sub Command2_Click()
Me.Adodc1.Recordset.AddNew
Call Command1_Click
End Sub
Private Sub Form_Load()
Me.Adodc1.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};" & "Dbq=" & App.Path & "\db1.mdb;"
Me.Adodc1.RecordSource = "表1"
Me.Adodc1.Refresh
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -