连接数据库问题用户定义类型未定义【vb6】0
Dim cnnImage As NewADODB.Connection
Dim rsImage As New ADODB.Recordset
Dim strSql As String
Dim Chunk() As Byte
Dim lngLengh As Long
Dim intChunks As Integer
Dim intFragment As Integer
Const ChunkSize = 1000
Const lngDataFile = 1为什么这样会提示用户定义类型未定义‘-----------------------------------------------------------这是数据库存图的源代码,网上找来的能运行
Dim cnnImage As New ADODB.Connection
Dim rsImage As New ADODB.Recordset
Dim strSql As StringDim Chunk() As Byte
Dim lngLengh As Long
Dim intChunks As Integer
Dim intFragment As Integer
Const ChunkSize = 1000
Const lngDataFile = 1
Private Sub cmdBrowse_Click()
'选择 JPG OR Bmp 文件
On Error Resume Next
With cmdlFilePath
.Filter = "JPG Files|*.JPG|Bitmaps|*.BMP|gif Files|*.gif"
.ShowOpen
txtFilePath.Text = .FileName
End With
End Sub
Private Sub cmdExit_Click()
End
End Sub
Private Sub cmdLast_Click()
On Error Resume Next
rsImage.MoveLast
Call ShowPic
End Sub
Private Sub cmdNext_Click()
On Error Resume Next
rsImage.MoveNext
Call ShowPic
End Sub
Private Sub cmdPrev_Click()
On Error Resume Next
rsImage.MovePrevious
Call ShowPic
End Sub
Private Sub cmdSave_Click()
'保存文件到数据库中
If Trim(txtFilePath.Text) = "" Then
MsgBox "未选择文件.!!", vbInformation + vbSystemModal, "保存出错"
Exit Sub
End If
If (Dir(Trim(txtFilePath.Text)) = "") Then Exit Sub
'以二进制方式打开文件
Open Trim(txtFilePath.Text) For Binary Access Read As lngDataFile
lngLengh = LOF(lngDataFile) ' 文件大小
If lngLengh = 0 Then Close lngDataFile: Exit Sub
intChunks = lngLengh \ ChunkSize
intFragment = lngLengh Mod ChunkSize
'新建记录
rsImage.AddNew
ReDim Chunk(intFragment)
Get lngDataFile, , Chunk()
rsImage!picImage.AppendChunk Chunk()
ReDim Chunk(ChunkSize)
For i = 1 To intChunks
Get lngDataFile, , Chunk()
rsImage!picImage.AppendChunk Chunk()
Next i
rsImage.Update
Close lngDataFile
Call ShowPic
End Sub
Private Sub cmdFirst_Click()
On Error Resume Next
rsImage.MoveFirst
Call ShowPic
End Sub
Private Sub Form_Load()
rsImage.LockType = adLockOptimistic
rsImage.CursorType = adOpenKeyset
cnnImage.Provider = "Microsoft.Jet.OLEDB.4.0"
strSql = App.Path & "\Image.mdb"
cnnImage.Open strSql
strSql = "Select * From ImageStore"
rsImage.Open strSql, cnnImage
If (rsImage.BOF = True) And (rsImage.EOF = True) Then Exit Sub
Call cmdFirst_Click
End Sub
Public Sub ShowPic()
On Error Resume Next
Open "pictemp" For Binary Access Write As lngDataFile
lngLengh = rsImage!picImage.ActualSize
intChunks = lngLengh \ ChunkSize
intFragment = lngLengh Mod ChunkSize
ReDim Chunk(intFragment)
Chunk() = rsImage!picImage.GetChunk(intFragment)
Put lngDataFile, , Chunk()
For i = 1 To intChunks
ReDim Buffer(ChunkSize)
Chunk() = rsImage!picImage.GetChunk(ChunkSize)
'建立图片临时文件
Put lngDataFile, , Chunk()
Next i
Close lngDataFile
FileName = "pictemp"Picture1.PaintPicture LoadPicture(FileName), 0, 0, Picture1.Width, Picture1.Height
'----按照picture大小缩放End SubPrivate Sub Frame2_DragDrop(Source As Control, X As Single, Y As Single)End SubPrivate Sub Picture1_Paint()
Picture1.PaintPicture mPic, 0, 0, Picture1.Width, Picture1.HeightEnd SubPrivate Sub txtFilePath_Change()End Sub
’--------------------------------------------------为什么我把这些声明粘贴上去却提示出错啊?