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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP/Interbase and BLOB 1

Status
Not open for further replies.

DRJ478

IS-IT--Management
Aug 10, 2001
2,264
US
I got stuck with a project that requires me to use ASP and Interbase 6. I'm most versatile with PHP. So, here's a question:
Data is retrieved from an ADODB recordset. I can display all field values except those that return type=205, and I already know that's a BLOB.
So I hunted for binary->string conversion functions, but no result with those. I used getChunk() etc., no luck.
I am able to print out the content to the browser using the response.binarywrite method, but I need the damn thing in a string variable. Any enlightening thoughts are welcome.
 
Are you using ODBC? If so, for whatever reason asp seems to prefer that blobs be placed at the end of each row of data in the recordset. Try changing your SQL to something like
Code:
SELECT myInt, myStr, myBlob FROM myTable
obviously using your actual field names, rather than SELECT * or some other order. (BTW, I don't know why this is true, but I got the tip from a Microsoft guy and it's done the trick for me ever since.)

Then when you retrieve the recordset, don't try working with the blob until you've set it to a string variable, a la
Code:
myBlobVar = rs("myBlob")
At this point you should be able to work with myBlobVar, assuming that the blob contains text. Working directly with rs("myBlob") will probably not work right, again "for some reason.
 
Thanks for the tip. However, no luck.
I have the BLOB in a variable, but nothing is displayed.
I wrote a little loop that shows fieldname and checks the type of the field and prints the value with response.binarywrite if it's 205, otherwise with response.write
That works well. However, I'm still not able to get the stuff into just a string. Just a simple assignment.
 
Out of curiousity, what does Len(yourString) return? I'm wondering if the assignment is simply not working or if there's some other problem.
 
The length returns absolutely nothing. Not a number, not a character, not en error.
 
Have you tried casting it as a string? What does something like:
Code:
myString = rs("myBlob")
Response.Write("Length: " & Len(CStr(myString)))
Response.Flush
return? That's got to return something (be certain to comment out any On Error Resume Next commands in your code).
 
Thanks for your help. The problem persists.
I have some more info:
1. Cstr(var) produces an error: Invalid use of Null: 'Cstr'
2. However, I checked with response.binarywrite recordset("fieldname") that the recordset contains the data and printed it into the response.

I could devise a way to just binarywrite it to the correct place, however, I am in a template parsing situation where the instance of the BLOB would be the only thing that is sent directly outside of the template context. If anyway avoidable I'd like to do this thing right.

It looks like the assignment is just not working.
 
Handy error message, at least. It looks like you're out of luck, to me... I think you're stuck with binarywrite.

If you come up with a better solution, please take a moment to post it here so future folks trying to solve a similar problem can take advantage of your experience.
 
ps. that's from google : ASP VB convert binary string

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
 
DreXor

I had used these functions to no avail.
I figured out - by footprinting the code - that the value disappears somwhere in a loop in the function that processes the template. I solved the problem by extracting the value to a local variable before entering the loop.
 
That's what I was trying to tell you above, where I said:
Then when you retrieve the recordset, don't try working with the blob until you've set it to a string variable
 
A star for you.
I didn't understand wholly what you meant. Coming from PHP - which IMHO is 100% predictable - it seemed inconceivable that such a thing had to be done to access a value that should be available anywhere in the local scope.
Grab it while you can. It get's lost somewhere along the path, but don't worry about that. Ouch.
 
Not sure I deserve a star since I wasn't very clear, but thanks. I'm glad you confirmed that's what you meant, and if I'd said "local variable" perhaps I would have been more clear.

And no, it makes no sense to me at all, either. Just seems to be the way it is. Certainly a bug.

I'm really glad you got it working!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top