Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Software > ADO Data > Appendchunk/Upd...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 4244 of 4320
Post > Topic >>

Appendchunk/Update of varbinary column fails on ODBC Linked table?

by ash.sozoh@[EMAIL PROTECTED] Jun 10, 2008 at 02:07 PM

I have a varbinary(max) column in a SQL Server table.  I am trying to
populate it through VBA code.
The code fails when the update to this column is done with a large
file and in a linked table environment in MS Access.
The linking is done using an ODBC system DSN.  It is interesting that
the code works fine with smaller files.

Const conChunkSize = 64000

Sub LoadJobOutputFileIntoDatabase(nJobPK&, strRe****tFile$)
    Dim Rcd As New ADODB.Recordset
    Dim strTempA$
    Dim nOffset&
    Dim strChunk As String
    Dim nLOBSize&

    strTempA = LoadFileIntoString(strRe****tFile)
    Rcd.Open "select * from brick_job where brick_job_pk=" & nJobPK,
CurrentProject.Connection, adOpenKeyset, adLockOptimistic
    nOffset = 0 ' Reset offset
    nLOBSize = LenB(strTempA)
    Do While nOffset < nLOBSize
        strChunk = LeftB(RightB(strTempA, nLOBSize - nOffset), _
            conChunkSize)
        Rcd!job_output.AppendChunk strChunk
        nOffset = nOffset + conChunkSize
    Loop
    Rcd.Update 'THIS STATEMENT GIVES RUN TIME ERROR
-2147217887(80040e21)
End Sub

However, the code works fine with ADO OLE Provider connection string.

Sub LoadJobOutputFileIntoDatabase(nJobPK&, strRe****tFile$)
    Dim Conn As New ADODB.Connection
    Dim Rcd As New ADODB.Recordset
    Dim strTempA$
    Dim nOffset&
    Dim strChunk As String
    Dim nLOBSize&

    Conn.Open "Provider=SQLOLEDB.1;User ID=user1;Password=pwd1;Initial
Catalog=Brickrpt;Data Source=butthead"
    strTempA = LoadFileIntoString(strRe****tFile)
    Rcd.Open "select * from brick_job where brick_job_pk=" & nJobPK,
Conn, adOpenKeyset, adLockOptimistic
    nOffset = 0 ' Reset offset
    nLOBSize = LenB(strTempA)
    Do While nOffset < nLOBSize
        strChunk = LeftB(RightB(strTempA, nLOBSize - nOffset), _
            conChunkSize)
        Rcd!job_output.AppendChunk strChunk
        nOffset = nOffset + conChunkSize
    Loop
    Rcd.Update
End Sub

Function LoadFileIntoString$(strFileName$)
    Dim nFile%, strTemp$, nFileLen&, strRec$, nCnt1&
    Const constBuffSize& = 2000000
    On Error GoTo LoadFileIntoString_Err
    LoadFileIntoString = ""
    nFile = FreeFile
    strRec = ""
    Open strFileName For Binary Access Read As #nFile
    nCnt1 = 0
    nFileLen = FileLen(strFileName)
    Do While True
        If EOF(nFile) Then
            Exit Do
        End If
        strTemp = Space(constBuffSize)
        Get #nFile, , strTemp
        If (nCnt1 + constBuffSize) > nFileLen Then
            strTemp = Mid(strTemp, 1, (nFileLen - nCnt1))
        End If
        strRec = strRec & strTemp
        nCnt1 = nCnt1 + Len(strTemp)
    Loop
    Close #nFile
    LoadFileIntoString = strRec
    Exit Function
LoadFileIntoString_Err:
    If nFile > 0 Then
        Close #nFile
    End If
    Exit Function
End Function

So, the question is, is there a limit on varbinary columns sup****ted
through ODBC?  If no then how I can fix the error.  I will appreciate
the help.

Ash
 




 2 Posts in Topic:
Appendchunk/Update of varbinary column fails on ODBC Linked tabl
ash.sozoh@[EMAIL PROTECTE  2008-06-10 14:07:24 
Re: Appendchunk/Update of varbinary column fails on ODBC Linked
"Ralph" <nt_  2008-06-10 18:58:07 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 13:52:05 CST 2008.