Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Picture into a SQL table

Status
Not open for further replies.

pmscraiova

Programmer
Dec 8, 2001
86
RO
I need to populate a table into a SQL databases with some pictures (photos).
The SQL table has two fields:
- FriendID = Integer type
- Picture = Image type
In VFP I made a remote view (rv_SQL_Photo) for this SQL table. I tried to insert the image like this:
Code:
Close Databases All
Open Database Photo
Set Database To Photo
Use Photo!rv_SQL_Photo In 0 Alias rv_photo
Select rv_photo

Begin Transaction
Insert Into rv_photo (FriendId) Values (13261)
Append General Picture From "c:\My Pictures\Eugen.jpg"
lSuccess = Tableupdate(.T.)

If lSuccess
	End Transaction
Else
	Rollback
Endif
I execute this program and I get a successfully transaction. But when I try to get this picture from ASP.NET I have no picture into this field.
I wonder where I made the mistake. Please help me… I am into a great hurry…
Thank you very much,
Eugen

P.S. Also when I put the picture from ASP.NET into the table and I try to get it from VFP (via remote view) I get the following error: “OLE object is invalid or corrupted”…
 
pmscraiova,

It would help if you could tell us what database you are using. Not all back ends support pictures, and those that do do not all have the same syntax.

In any case, it is unlikely that your code will work, because you are relying on a General field, which is specific to VFP.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Hello Mike,
Thank you for your answer. The database in which I must store the pictures is a MS SQL Server 2000 SP3 one. I used the “Append general” to insert the picture into the remote view because I don’t know another possibility to do it. I’ll appreciate any suggestion from you.
Thanks again,
Eugen
 
Another possibility on FoxPro side is memo(binary)+STRTOFILE/FILETOSTR. However I don't know, which data type is on sql server suitable for long binary data, but sure there is one.
 
pmscraiova,

In SQL Server, you use an 'Image' field to hold pictures (or other binary data). Rather than update these with remote views, you might need to send T-SQL code to the server using SQL pass-through.

I don't know the exact syntax off-hand, but the command you need is WRITETEXT. You can find more details in the T-SQL Help. Once you have found the exact command to use, you send it to the server using SQLEXEC().

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top