Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2004
    Posts
    4

    Red face Unanswered: sql2000i and blob (longbinaryvar)

    Hi!
    Have anyone resolved how store blob to pvsw database?
    I've tested with many tools without any success.
    If you know VB code sample or any that might work I'll happy.

    Work around I have:
    Images in 'C:\temp\image.bmp'
    Pvsq Demodata with table pictures (id(int),description(str),imagedata(blob). I need to move all images from local to database for later use in Crystal reports 8.5, so I can't use file path.

    With odbc and VB I can create table, add and search records besides blobs
    With Access, if I add emb. ole images one by one, it works ok, but I have 5000 images to handle.

    Any ideas ? -thanks-

  2. #2
    Join Date
    Dec 2001
    Posts
    1,109
    Provided Answers: 4
    How about posting the VB code that doesn't work for you? Also, what error or problem are you having with storing. Another thing you might consider would be to convert the images to JPG or some other format that's smaller than BMP.
    Here's some code I found:
    Code:
      Dim oPict As StdPicture
        
        Set oPict = LoadPicture(sFileName)
        
        'Exit Function if this is NOT a picture file
        If oPict Is Nothing Then
            MsgBox "Invalid Picture File!", vbOKOnly, "Oops!"
            SavePictureToDB = False
            Exit Function
        End If
        
        RS.AddNew
        Set strStream = New ADODB.Stream
        strStream.Type = adTypeBinary
        strStream.Open
        strStream.LoadFromFile sFileName
        RS.Fields("id") = 1
        RS.Fields("image").Value = strStream.Read
        RS.Update
    Last edited by mirtheil; 03-10-04 at 09:06.
    Mirtheil Software
    Certified Pervasive Developer
    Certified Pervasive Technician
    Custom Btrieve/VB development
    http://www.mirtheil.com
    I do not answer questions by email. Please post on the forum.

  3. #3
    Join Date
    Mar 2004
    Posts
    4
    Ok, this stream methode works with Mysql, access.... so, when I try to pervasive 2000i, error "Runtime (-2147217887 (80040e4)" occures.
    Any other good ideas? - I could not find any from pervasive, ms or any other souces from net.

  4. #4
    Join Date
    Dec 2001
    Posts
    1,109
    Provided Answers: 4
    First, you should really post your code so we can know what you're doing. Also, where within the code do you get the error message?
    When you post your code, post the connection string, the connection, and the part that writing to the database.
    Mirtheil Software
    Certified Pervasive Developer
    Certified Pervasive Technician
    Custom Btrieve/VB development
    http://www.mirtheil.com
    I do not answer questions by email. Please post on the forum.

  5. #5
    Join Date
    Mar 2004
    Posts
    4
    'The code I use for test is:

    Option Compare Database

    ' from sub main I call AddBinaryDataRow() function.

    ' this function is for make connection
    Function GetSQLConnA()
    Dim GlobalADOConnA As New ADODB.Connection
    Dim rstH As New ADODB.Recordset
    Dim sConStr As String
    ' I have tested with DNS and path with same error
    GlobalADOConnA.Open "Provider=PervasiveOLEDB;Data Source=x:\pvsw\demodata"
    If GlobalADOConnA.State <> adStateOpen Then
    Set GlobalADOConnA = Nothing
    Set rstH = Nothing
    MsgBox "could not connect"
    End
    End If
    rstH.Open "WebData", GlobalADOConnA, adOpenDynamic, adLockBatchOptimistic, adCmdTableDirect
    rstH.MoveFirst
    Do
    rstH.MoveNext
    Loop Until rstH.EOF
    rstH.Close

    GlobalADOConnA.CursorLocation = adUseServer
    Set GetSQLConnA = GlobalADOConnA

    End Function

    Function AddBinaryDataRow()
    Const adCmdText = 1
    Const adOpenDynamic = 2
    Const adLockOptimistic = 3
    Const adOpenKeyset = 1
    Dim ByteData() As Byte 'Byte array for Blob data.
    Dim SourceFile As Integer
    Dim oPict As StdPicture

    Dim SQL, Conn, RS As ADODB.Recordset
    sFileName = "c:\temp\setup.bmp"
    Set Conn = GetSQLConnA()
    Set RS = CreateObject("ADODB.Recordset")
    SQL = "Select ID, Description, BinaryColumn from WebData Where 1=0"
    Set RS = CreateObject("ADODB.Recordset")
    RS.Open SQL, Conn, adOpenKeyset, adLockOptimistic, adCmdText
    RS.AddNew
    Set strStream = New ADODB.stream
    strStream.Type = adTypeBinary
    strStream.Open
    strStream.LoadFromFile sFileName
    RS.Fields("ID") = 117
    RS.Fields("Description") = "Description Text"
    ' When try the next stament error occures
    RS.Fields("BinaryColumn") = strStream.Read
    RS.Update
    RS.Close
    AddBinaryDataRow = RS("ID")
    End Function

  6. #6
    Join Date
    Dec 2001
    Posts
    1,109
    Provided Answers: 4
    I think I see your problem. With the OLEDB provider, you are limited to 64K without having to use CHunk operations. If you use the ODBC bridge, then you won't need to use the Chunk code. If you change this:
    Code:
    GlobalADOConnA.Open "Provider=PervasiveOLEDB;Data Source=x:\pvsw\demodata"
    to:
    Code:
    GlobalADOConnA.Open "DSN=DataSourceName"
    it should work.
    Mirtheil Software
    Certified Pervasive Developer
    Certified Pervasive Technician
    Custom Btrieve/VB development
    http://www.mirtheil.com
    I do not answer questions by email. Please post on the forum.

  7. #7
    Join Date
    Mar 2004
    Posts
    4

    Talking

    Thanks!

    I've try this for weeks.....! It works!
    (Why I don't ask that earlier ? - just wondering -)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •