读取adobe.stream时溢出

时间:2019-02-19 11:48:36

标签: excel vba

我有下面的代码,将一些数据保存到数据库中,但是运行代码时,出现Overflow错误。知道有什么问题吗?是否有什么需要补充才能改善的?

Open_DB MSACCString
Set RS = New ADODB.Recordset

'rs.Open MSACCString, cn, adOpenStatic, adLockOptimistic, adCmdText
Dim SearchID As String
Dim strStream As ADODB.Stream

SearchID = Card_Screen.Range("Sh_EmpID").Value

With RS
    .Index = "NA_EMP_ID"
    .CursorLocation = adUseServer
    .Open "ID_Card", cn, 1, 3, adCmdTableDirect
    .Seek SearchID

    If Not RS.EOF Then
        'rs.Fields("NA_EMP_ID") = Range("SH_EMPID").Value
        RS.Fields("First") = Range("FName").Value
        RS.Fields("Third") = Range("TName").Value
        RS.Fields("DOB") = Range("Sh_DOB").Value
        RS.Fields("PassportNumber") = Range("Sh_Passport").Value

        If Sheets("ID_Entry").OptionButton1.Value = True Then
            RS.Fields("EmpType") = Sheets("ID_Entry").OptionButton1.Caption
        ElseIf Sheets("ID_Entry").OptionButton2.Value = True Then
            RS.Fields("EmpType") = Sheets("ID_Entry").OptionButton2.Caption
        Else
            MsgBox "Please select employee type"
        End If

        If CheckFolder(Card_Screen.Range("SH_Photo"), Card_Screen.Range("Sh_EmpID") & ".jpg") Then
            Set stringStream = New ADODB.Stream
            stringStream.Type = adTypeBinary
            stringStream.Open
            stringStream.LoadFromFile Range("Photo").Value
            RS.Fields("Photo").Value = stringStream.Read
        End If

        Range("Photo") = imageToFile(TempPath & Trim(RS("NA_Emp_ID")) & ".jpg", RS("Photo"))
        Range("Photo") = Range("FName").Value
        .Update
        .Close
    End If
End With

0 个答案:

没有答案