If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Pervasive.SQL > sql2000i and blob (longbinaryvar)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-10-04, 01:57
kelju kelju is offline
Registered User
 
Join Date: Mar 2004
Posts: 4
Red face 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-
Reply With Quote
  #2 (permalink)  
Old 03-10-04, 07:59
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
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
__________________
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.

Last edited by mirtheil; 03-10-04 at 08:06.
Reply With Quote
  #3 (permalink)  
Old 03-17-04, 15:54
kelju kelju is offline
Registered User
 
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.
Reply With Quote
  #4 (permalink)  
Old 03-17-04, 16:30
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
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.
Reply With Quote
  #5 (permalink)  
Old 03-22-04, 12:44
kelju kelju is offline
Registered User
 
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
Reply With Quote
  #6 (permalink)  
Old 03-22-04, 13:46
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
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.
Reply With Quote
  #7 (permalink)  
Old 03-22-04, 15:36
kelju kelju is offline
Registered User
 
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 -)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On