473,465 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

A safe array of bytes is expected as an argument

Hi there,
I am using the ASP to PDF component from www.asppdf.com and have an
unusual problem when displaying a blob from the database.

When there is an image stored in my SQL2000 field of type image, and I
use this:

Params = "x=337; y=408; scalex=.33; scaley=.33"
Set SigImage = Doc.OpenImageBinary(rsMotor("Photo").Value)
Page.Canvas.DrawImage SigImage, Params

The image gets drawn in the PDF and everything is fine.

If I try to create a PDF using the same record, but where the image
filed is NULL, I get this error:

Persits.PdfManager.1 error '800a002f'

A safe array of bytes is expected as an argument.

So I thought I need to check if the field isn't null before attempting
to draw it onto the canvas, so I tried this:

If LEN(rsMotor("Photo").Value) 0 Then
'Insert Photo
Params = "x=337; y=408; scalex=.33; scaley=.33"
Set SigImage = Doc.OpenImageBinary(rsMotor("Photo").Value)
Page.Canvas.DrawImage SigImage, Params
End if

Using this with an image stored in the field gives me the same error
message, its only when the field is empty that the above code works and
doesn't draw the image on the PDF.

I also tried this:

If NOT(ISNULL(rsMotor("Photo").Value)) Then
'Insert Photo
Params = "x=337; y=408; scalex=.33; scaley=.33"
Set SigImage = Doc.OpenImageBinary(rsMotor("Photo").Value)
Page.Canvas.DrawImage SigImage, Params
End if

But still got the same error.

If I don't use any checking code, and have NULL in the image field, I
get the same error. This must be something to do with the binary
content, how can I detect if there is binary content?

Steve
Mar 10 '08 #1
7 3920
Jon Paal [MSMD] wrote:
http://databases.aspfaq.com/database...p-my-html.html

http://databases.aspfaq.com/database...snull-sql.html
Hi Jon,
Thanks for the pointers, I like the idea of doing it in SQL, as I am
already using a view to get the data to the page.

I am still open to other ideas.

Cheers,

Steve
Mar 10 '08 #3
Dooza wrote:
Jon Paal [MSMD] wrote:
>http://databases.aspfaq.com/database...p-my-html.html
http://databases.aspfaq.com/database...snull-sql.html

Hi Jon,
Thanks for the pointers, I like the idea of doing it in SQL, as I am
already using a view to get the data to the page.

I am still open to other ideas.

Cheers,

Steve
I have gone for a temporary solution, as it seems that as soon as you do
a length check or isnull check on the binary field it becomes unusable.

I have used this in my SQL view:

CASE WHEN (MC.mct_photo IS NULL)
THEN '0' ELSE '1' END AS PhotoCheck

And this on my page:

If rsMotor("PhotoCheck") = 1 Then
'Insert Photo
Params = "x=337; y=408; scalex=.33; scaley=.33"
Set SigImage = Doc.OpenImageBinary(rsMotor("Photo").Value)
Page.Canvas.DrawImage SigImage, Params
End if

Does anyone have any experience with using binary data in asp? Am I
right in thinking that the starting position has changed due to the
length check? Is there a way to reset the starting position?

Cheers,

Steve
Mar 10 '08 #4
Dooza wrote:
I have gone for a temporary solution, as it seems that as soon as you
do a length check or isnull check on the binary field it becomes
unusable.
I have used this in my SQL view:

CASE WHEN (MC.mct_photo IS NULL)
THEN '0' ELSE '1' END AS PhotoCheck

And this on my page:

If rsMotor("PhotoCheck") = 1 Then
'Insert Photo
Params = "x=337; y=408; scalex=.33; scaley=.33"
Set SigImage = Doc.OpenImageBinary(rsMotor("Photo").Value)
Page.Canvas.DrawImage SigImage, Params
End if

Does anyone have any experience with using binary data in asp? Am I
right in thinking that the starting position has changed due to the
length check? Is there a way to reset the starting position?
Rather than checking for NULL, use DATALENGTH:
http://msdn2.microsoft.com/en-us/library/ms173486.aspx


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Mar 10 '08 #5
Dave Anderson wrote:
Dooza wrote:
>I have gone for a temporary solution, as it seems that as soon as you
do a length check or isnull check on the binary field it becomes
unusable.
I have used this in my SQL view:

CASE WHEN (MC.mct_photo IS NULL)
THEN '0' ELSE '1' END AS PhotoCheck

And this on my page:

If rsMotor("PhotoCheck") = 1 Then
'Insert Photo
Params = "x=337; y=408; scalex=.33; scaley=.33"
Set SigImage = Doc.OpenImageBinary(rsMotor("Photo").Value)
Page.Canvas.DrawImage SigImage, Params
End if

Does anyone have any experience with using binary data in asp? Am I
right in thinking that the starting position has changed due to the
length check? Is there a way to reset the starting position?

Rather than checking for NULL, use DATALENGTH:
http://msdn2.microsoft.com/en-us/library/ms173486.aspx
Hi Dave, thats a new one on me, is it SQL only, or can I use it in
ASP/VBScript?

Steve
Mar 10 '08 #6
Dooza wrote:
>>CASE WHEN (MC.mct_photo IS NULL)
THEN '0' ELSE '1' END AS PhotoCheck

Rather than checking for NULL, use DATALENGTH:
http://msdn2.microsoft.com/en-us/library/ms173486.aspx

Hi Dave, thats a new one on me, is it SQL only, or can I use
it in ASP/VBScript?
It's only VBScript if you can find it here:
http://msdn2.microsoft.com/en-us/library/d1wf56tt.aspx

The link I provided is Transact-SQL. I meant for you to understand that you
can use it in this manner:

SELECT
MC.mct_photo,
DATALENGTH(MC.mct_photo) AS Bytes,
...
FROM [Your Table]

This does not require a conditional evaluation in the database. You will be
using one, regardless, in your web script, so why add another?

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Mar 10 '08 #7
Dave Anderson wrote:
The link I provided is Transact-SQL. I meant for you to understand
that you
can use it in this manner:

SELECT
MC.mct_photo,
DATALENGTH(MC.mct_photo) AS Bytes,
...
FROM [Your Table]

This does not require a conditional evaluation in the database. You
will be
using one, regardless, in your web script, so why add another?
That makes perfect sense and works perfectly too. It will also allow me
to keep an eye on the size of images in the table.

Thanks again!

Steve
Mar 11 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Vaca Louca | last post by:
Hello, I write an ISAPI authentication module which uses Berkeley DB and want it to be as efficient as possible. Both ISAPI and BerkeleyDB use arrays of chars (char *) to pass and receive...
6
by: Herrcho | last post by:
in K&R Chapter 6.3 it mentions two methods to calculate NKEYS. and points out the first one which is to terminate the list of initializers with a null pointer, then loop along keytab until the...
26
by: Brett | last post by:
I have created a structure with five fields. I then create an array of this type of structure and place the structure into an array element. Say index one. I want to assign a value to field3 of...
0
by: k1ckthem1dget | last post by:
I need to display the unsorted list of names and display the sorted list of names. My program is getting a bunch of errors though, and i dont know why. I am getting the following errors. 28:...
2
by: k1ckthem1dget | last post by:
I need to display the unsorted list of names and display the sorted list of names. My program is getting a bunch of errors though, and i dont know why. I am getting the following errors. 28:...
272
by: Peter Olcott | last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a I think that the operator() member function does not work correctly, does anyone else know how to make a template for making two...
95
by: hstagni | last post by:
Where can I find a library to created text-based windows applications? Im looking for a library that can make windows and buttons inside console.. Many old apps were make like this, i guess ...
29
by: Jon Slaughter | last post by:
Is it safe to remove elements from an array that foreach is working on? (normally this is not the case but not sure in php) If so is there an efficient way to handle it? (I could add the indexes to...
152
by: vippstar | last post by:
The subject might be misleading. Regardless, is this code valid: #include <stdio.h> void f(double *p, size_t size) { while(size--) printf("%f\n", *p++); } int main(void) { double array = { {...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.