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 > Data Access, Manipulation & Batch Languages > Delphi, C etc > ADO stream object

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-30-02, 06:39
fbord fbord is offline
Registered User
 
Join Date: Oct 2002
Posts: 7
Unhappy ADO stream object

I must save a file into a SQL Server table and read it back and save it somewhere.
I have tried it in VB and it works; unfortunately I must use VFP :-(
In VFP I can read the data from the table and save it to disk, but not read data from a file and saving it into a table.

this works in VB:
Set mStream = New ADODB.Stream
mStream.Type = adTypeBinary
mStream.Open
mStream.LoadFromFile App.Path & "\" & sFileName
rs.AddNew
rs.Fields("descr").Value = sFileName
rs.Fields("image1").Value = mStream.Read
rs.Update

this DOES NOT work in VFP:
loStream = CreateObject("ADODB.Stream")
loConnection.Open (lcConnStr)
loRS.OPEN(lcSQL,loConnection,2,3)
loStream.TYPE = 1
loStream.Open
loStream.LoadFromFile(lcfilename)
loRS.AddNew
loRS.Fields("descr").Value = lcfilename
loRS.Fields("
Reply With Quote
  #2 (permalink)  
Old 10-30-02, 17:20
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
This seems like a job for DTS - is there a reason why you are not using dts ?
Reply With Quote
  #3 (permalink)  
Old 10-31-02, 03:41
fbord fbord is offline
Registered User
 
Join Date: Oct 2002
Posts: 7
Sorry, someway some of my post was cut.

up to this line it works:
loRS.Fields("descr").Value = lcfilename

The following line does not:
loRecordSet.Fields("image1").value = loStream.read(-1)

it says that it cannot find the ".value" property. without it, it generates an error "Function argument value, type or count is invalid"

Is it that VFP cannot properly deal with the Variant data type that the Read Method returns, at least when it tries to insert it into an Image Field?
About DTS, I must admit I have no clue how I can call it from my procedure! (especially from VFP.) Sounds like a good idea, though. Any help would be greatly appreciated. My current idea is to make a VB DLL that deals with the Stream Object, and call it from VFP.
Thanks

Fabrizio
Reply With Quote
  #4 (permalink)  
Old 11-01-02, 14:21
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
Which version of sql server are you using ? Do you have access to the sql server machine ? What permissions do you have ?
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On