vb连接mysql出现的问题_连接数据库问题用户定义类型未定义【vb6】

连接数据库问题用户定义类型未定义【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

’--------------------------------------------------为什么我把这些声明粘贴上去却提示出错啊?

  • 0
    点赞
  • 0
    收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:数字20 设计师:CSDN官方博客 返回首页
评论

打赏作者

weixin_39838798

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值