Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CursorAdapter sweet CursorAdapter
Message
From
29/11/2002 10:20:37
Emanuele Bonin
EB Soluzioni Informatiche
Tezze S/B, Italy
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
CursorAdapter sweet CursorAdapter
Miscellaneous
Thread ID:
00728167
Message ID:
00728167
Views:
50
I'm using CursorAdapter and i'm trying to save images (but in my intention could be ani type of file) on a MS SQL SERVER where the data must be stored on image field that i map on client in a MEMO BINARY FIELDS.

I have some doubt, because using little images (3k bitmap) al work fine (i can retriueve the correct image), but when i'm trying to save a larger file (i've tried with a 37k bitmap) the update command emit the follow error:
----------------------------------------------------------------------------
Connectivity error: Operand type clash: text is incompatible with image
----------------------------------------------------------------------------
Below there isa the Sql Script to create the test table and the vfp program that i used.

What is the problem ? there is a problem ? Where ?? in My Head or in the Beta ?

Thanx in Advance.


-- Script to create SQL TABLE table from query analyzer
CREATE TABLE Images (
Id_Images INTEGER NOT NULL,
Picture IMAGE NULL,
CONSTRAINT PK_Images PRIMARY KEY
(
Id_Images
)
)
-----

*** Start of vfp Program
SQLSETPROP(0, 'displogin', 1)
SET SAFETY OFF


**cImageFile = 'arrows.bmp' && 3 K Bitmap
cImageFile = 'logo.bmp' && 37 K Bitmap

nHandle = SQLSTRINGCONNECT('DRIVER=SQL SERVER;SERVER=WXP04;APP=Microsoft Visual FoxPro;WSID=WXP04;DATABASE=ADB_DEMO;Trusted_Connection=Yes')
IF nhandle <=0
RETURN
ENDIF

o = CREATEOBJECT('CursorAdapter')
o.DatasourceType = "ODBC"
o.buffermodeoverride = 5
o.Datasource = nHandle
o.updatetype = 1
o.FetchAsNeeded = .T.
o.KeyFieldList = 'Id_Images'
o.CursorSchema = 'Id_Images I, Picture M'
o.SelectCmd = "SELECT Id_Images, Picture FROM Images"
o.Tables = 'Images'
o.Alias = 'Images'
o.updatablefieldlist = 'Id_Images, Picture'
o.UpdateNameList = "Id_Images Images.Id_Images, Picture Images.Picture"
o.wheretype = 1
o.SendUpdates = .T.
o.AllowUpdate = .T.
o.AllowInsert = .T.
o.AllowDelete = .T.

IF o.CursorFill(.T.)
SET NOCPTRANS TO picture && Picture Field is a Memo Binary
IF RECCOUNT() = 0 && If there is no records i'll create one
&& This example works with only one record, so i can run it continuously
APPEND BLANK
REPLACE Id_Images WITH 1
*!* ELSE
*!* && I Retrieve the Bitmap
*!* STRTOFILE(Picture, 'BitmapOut.BMP')
ENDIF

REPLACE Picture WITH FILETOSTR(cImageFile) && Copy Bytes to Picture

IF !TABLEUPDATE(1, .F., o.Alias)
MESSAGEBOX('Error on Update!' + CHR(13) + MESSAGE())
ENDIF

ELSE
MESSAGEBOX('Error on retrieving!' + MESSAGE())
ENDIF

*** End of vfp Program
bye, Emanuele!
In the beginning the Universe was created.
This has made a lot of people very angry and been widely regarded as a bad move.
Next
Reply
Map
View

Click here to load this message in the networking platform