Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

blob & image

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-28-2007, 03:44 PM
Senior Member
 
Join Date: Jul 2007
Location: Michigan Usa
Posts: 176
Awards Showcase
Beta Tester 
Total Awards: 1
Default blob & image

Ok I have added a picture table to a dbase that I have created. I am saving a form.image to a image file and thought I would try to save to the dbase instead. I found the example in the sql help file of how to load the file into the dbase and how to retrieve it from the dbase and have succeed with no problems. My question is how do you save form1.image directly to the dbase instead of to a file and then the dbase.

Well ok maybe 1

dennishea
Reply With Quote
  #2 (permalink)  
Old 08-28-2007, 03:55 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,734
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

You will need to use ImageLibEx library to save the image to a temporary file and then FileToBlob to add the file to the database.
There is no direct way to serialize an image and store it in the db.
Reply With Quote
  #3 (permalink)  
Old 08-28-2007, 04:56 PM
Senior Member
 
Join Date: Jul 2007
Location: Michigan Usa
Posts: 176
Awards Showcase
Beta Tester 
Total Awards: 1
Default image & blob

Thanks for the quik reply Erel. I was hopeing, oh well. Well on to setting that path up. Again thanks for your help and a very nice programming language that you just keep making better & better. Am looking forward to the future of basic4ppc.

dennishea
Reply With Quote
  #4 (permalink)  
Old 08-29-2007, 12:54 PM
Senior Member
 
Join Date: Jul 2007
Location: Michigan Usa
Posts: 176
Awards Showcase
Beta Tester 
Total Awards: 1
Default

I have tried several ways to use this textbox (txtAngle.text) to replace smiley.gif in the line of code below. I want it to use the textbox information in place of smiley.gif. Everything works fine if I type in the name of the file in place of smiley.gif but I can't seem to get the syntax right for using a textbox. Does anybody know the way to replace


----------------------------------------------- txtAngle.text----
cmd.CommandText = "INSERT INTO pictures values('smiley.gif'," &
-------------------------- txtAngle.text---------
cmd.FileToBLOB(AppPath & "\smiley.gif") & ")"

dennishea
Reply With Quote
  #5 (permalink)  
Old 08-29-2007, 01:07 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

You have smiley.gif as a string literal and cannot just replace a literal with a variable value - you need to build the variable value into a string

i.e replace "... 'smiley.gif'..."
with "...'" & txtAngle.text & "'..."

doublequote - characters - singlequote doublequote & txtAngle.text & doublequote singlequote characters doublequote
Reply With Quote
  #6 (permalink)  
Old 08-29-2007, 02:28 PM
Senior Member
 
Join Date: Jul 2007
Location: Michigan Usa
Posts: 176
Awards Showcase
Beta Tester 
Total Awards: 1
Default

agraham

This is what I am trying to get to work.

cmd.CommandText = "INSERT INTO pictures(name)values ('" & txtAngle.text & "', " cmd.FileToBLOB & AppPath & "\" & "'" txtAngle.text "')"

It's the only thing I have been able to get to compile and run up to it, then it spits out error. Basicly it is saying that it can't find the file. The textbox txtAngle.text is giving it it's contents, but they look like this 'Al 0008.bmp')' and I don't know why it has single quotes and the close character. I figure it is to do with the way I have it coded but can't seem to get it to compile any other way. This one is stubborn.

dennishea
Reply With Quote
  #7 (permalink)  
Old 08-29-2007, 02:56 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

This last bit looks wrong to me

... cmd.FileToBLOB & AppPath & "\" & "'" txtAngle.text "')"

There are two missing parentheses I think and if your original command using smiley.gif is correct then the single quotes are not needed in a parameter to FileToBlob. Try this

... & cmd.FileToBLOB (AppPath & "\" & txtAngle.text) & ")"

I think that FileToBlob needs to be executed while building the string, not be part of it
Reply With Quote
  #8 (permalink)  
Old 08-29-2007, 03:06 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

I just noticed that the file name you posted 'Al 0008.bmp' has a space in it. This is possibly not good as you may then need to double quote the filename to FileToBlob. If can, try it with a filename with no spaces otherwise you may be fighting on two fronts. Also if the single quotes and closing parenthesis really are in txtAngle.text then that seems wrong to me as well - surely it should only have a filename string in it? If you have put them in then remove them - they are clouding the issue.

EDIT: I've downloaded the SQL library and tried the example - this works with just the filename string in the text box

"INSERT INTO pictures values('" & txtAngle.Text & "'," & cmd.FileToBLOB(AppPath & "\" & txtAngle.Text) & ")"

Last edited by agraham : 08-29-2007 at 03:47 PM.
Reply With Quote
  #9 (permalink)  
Old 08-29-2007, 04:25 PM
Senior Member
 
Join Date: Jul 2007
Location: Michigan Usa
Posts: 176
Awards Showcase
Beta Tester 
Total Awards: 1
Default

This was my last attemp for the day.
This doesn't work, I don't understand. This line of code shouldn't be any different then the below it and the one below works good.

---------------doesn't work-----------------------------------------
cmd.CommandText = "INSERT INTO pictures values('" & txtAngle.text & "', & cmd.FileToBLOB(" AppPath " & "\" & '" & txtAngle.text & "') &")"

------------------does work----------------------------------------
cmd.CommandText = "insert into WorkData values('" & txtInternal.Text & "','" & txtColdOd.Text & "','" & txtColdFp.Text & "','" & txtHotOd.Text & "','" & txtHotFp.Text & "','" & txtAmtWire.Text & "','" & txtPph.Text & "','" & txtWireSize.Text & "','" & txtCyctime.Text & "','" & txtMach.Text &"')"

delete , update and insert uses the format above and seems to be working fine. The data base checks out fine when I use these three commands with the above format. The top one with filetoblob is being a real stickleer. Well tomorrow another day. Being a third shift person it's my bed time. Tomorrow is another day. Have a good one all.

dennishea
Reply With Quote
  #10 (permalink)  
Old 08-29-2007, 05:09 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
"INSERT INTO pictures values('" & txtAngle.text & "', & cmd.FileToBLOB(" AppPath " & "\" & '" & txtAngle.text & "') &")"
Compare your failing command string (above) with the one I posted earlier that does work (below).
Quote:
"INSERT INTO pictures values('" & txtAngle.Text & "'," & cmd.FileToBLOB(AppPath & "\" & txtAngle.Text) & ")"
Your present problems are with the filename parameter of cmd.FileToBLOB(...).

1) You are quoting AppPath as a string literal so it will not be evaluated correctly. Also in a previous post I said
Quote:
the single quotes are not needed in a parameter to FileToBlob
2) You are trying to put add these unnecessary single quotes around the filename and are producing a string that doesn't parse correctly.

SQLlite needs literal strings, like a filename, to be quoted with single quotes. The values(....) bit of the statement is executed by the SQLlite engine and so needs those single quotes. The cmd.FileToBLOB(...) bit of the statement is executed by B4PPC while it is building the string for cmd.commandText and so needs either a string literal quoted by double quotes or (as in this case) a string expression that evaluates to a valid path.
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 Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question: BLOB-Data within Tablecontrol ? schaujo Questions (Windows Mobile) 2 01-27-2008 05:49 PM
Move an image inside an image control Cableguy Questions (Windows Mobile) 5 05-14-2007 07:40 PM
SQL BLOB problem HARRY Questions (Windows Mobile) 9 05-10-2007 06:13 PM


All times are GMT. The time now is 11:05 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0