VB保存图片文件到数据库
2016-03-12 23:48
411 查看
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.name, 表1.file FROM 表1;
Private Sub Command3_Click()
'
strSQL = "SELECT 表1.编号, 表1.name, 表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.name, 表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
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.name, 表1.file FROM 表1;
Private Sub Command3_Click()
'
strSQL = "SELECT 表1.编号, 表1.name, 表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.name, 表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
相关文章推荐
- Win7系统上安装SQL Server 2008
- Please read “Security” section of the manual to find out how to run mysqld as root!错误解决(转)
- oracle创建表空间
- 配置mysql允许远程连接的方法
- MySql优化【6】--压力测试脚本
- MySql优化【3】--SQL语句优化
- MYSQL插入数据,修改数据,误操作怎么恢复实例
- 企业如何给MYSQL创建表,查询表,创建索引实例
- [原创]安装Oracle 11gR2,以及如何在win8下使用plsql develper连接Oracle数据库 ,在这里和大家分享下
- 企业是怎么给MYSQL赋予用户权限
- MYSQL数据库查询删除创建企业基本知识
- Oracle Database 11g Express Edition 如何创建数据库
- << 电子电路 >>电子电路 Mysql
- 数据库事务笔记
- Oracle常见错误总结
- mysql数据类型
- mysql常见错误
- 使用SKIP-GRANT-TABLES 解决 MYSQL ROOT密码丢失(转)
- ubuntu下pdo mysql的安装
- linux下mysql的简单配置及监控