Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Saving a picture from a file to the database


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-27-2008, 02:35 PM
Junior Member
 
Join Date: Apr 2008
Posts: 11
Default Saving a picture from a file to the database

Hi all,

It's me again.

Here is another problem I have.

I have a "Person" table with a blob field for the picture of the person.
I created a form to enter the name of the person, and there is an Image field.
I added a contextual menu on this image to allow the user to load the image from a file.
So, in the code, I use a OpenDialog window (so that the user can select a picture file)

Here is the code :
Code:
If ODPImage.Show <> cCancel Then
	Fichier = ODPImage.File
	ImgPBlob.Image = ODPImage.File
	FileClose (Fichier)
	strSQL = "Update personnes set P_Image = " & cmd.FileToBLOB(Fichier) & " Where P_ID = " & TBPID.Text
	cmd.CommandText = strSQL
	cmd.ExecuteNonQuery
End If
The problem is that I have an error message :
"The process cannot access the file '<__name_of_file_here__>' because it is being used by another process"

I tried to close the file (as you can see with the command FileClose), but it does not work.

And another extra question :
How do I remove a picture in the table ?
Is it :
Code:
Update personnes set P_Image = NULL where . . .
or
Code:
Update personnes set P_Image = '' where . . .
or
Code:
Update personnes set P_Image = "" where . . .
or
Code:
something else ??
Thanks a lot in advance.
Reply With Quote
  #2 (permalink)  
Old 04-27-2008, 04:33 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,199
Default

Try to first save the image to the database and then show it.
Code:
If ODPImage.Show <> cCancel Then
	Fichier = ODPImage.File
	strSQL = "Update personnes set P_Image = " & cmd.FileToBLOB(Fichier) & " Where P_ID = " & TBPID.Text
	cmd.CommandText = strSQL
	cmd.ExecuteNonQuery
        ImgPBlob.Image = ODPImage.File 
End If
Reply With Quote
  #3 (permalink)  
Old 04-27-2008, 05:22 PM
Junior Member
 
Join Date: Apr 2008
Posts: 11
Default

Yes, works like a charm !

Thanks a lot !
Reply With Quote
  #4 (permalink)  
Old 05-09-2008, 10:20 PM
willisgt's Avatar
Senior Member
 
Join Date: Aug 2007
Location: Nacogdoches, Texas USA
Posts: 157
Default

In the original example at top, what type of objects are ODPImage and ImgPBlob?

Gary
__________________
PC: Windows XP Pro SP3 / Basic4PPC v6.5
PPC: HTC 8925 (AT&T Tilt) / Windows Mobile 6
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
"Error saving file" N1c0_ds Bug Reports 0 09-14-2008 01:25 AM
Picture while loading derez Questions & Help Needed 2 01-01-2008 09:27 AM
Saving an image to a file Erel Additional Libraries 8 09-04-2007 08:14 PM
How to convert an Access database to a sqlite database Peter Code Samples & Tips 5 07-24-2007 04:20 PM
Saving the screen to a file derez Questions & Help Needed 3 07-04-2007 12:08 PM


All times are GMT. The time now is 01:32 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0