Setting an image datatype to NULL

R

Roger Withnell

I'm updating a record by opening a recordset, setting the fields and the
updating it with objRS.Update.

I need to set an image datatype to NULL. objRS("field") = NULL works for
datatypes int and varchar but not for datatype image, although there is no
error - the image field still contains the image!

I'm using SQL server and running an UPDATE statement including image = NULL
works.

Any help would be much appreciated.
 
A

Aaron [SQL Server MVP]

Use an UPDATE statement, then you don't have to worry about how the word
"null" is misinterpreted in the various layers.

conn.execute "UPDATE tbl SET imageCOLUMN = NULL [...where...]", , 129
 
R

Roger Withnell

I'm using AspUpload to upload two images at the same time. Don't see how I
can do that with an UPDATE, so I'm stuck with updating a record set.

Any other ideas appreciated.

Aaron said:
Use an UPDATE statement, then you don't have to worry about how the word
"null" is misinterpreted in the various layers.

conn.execute "UPDATE tbl SET imageCOLUMN = NULL [...where...]", , 129

--
http://www.aspfaq.com/
(Reverse address to reply.)




Roger Withnell said:
I'm updating a record by opening a recordset, setting the fields and the
updating it with objRS.Update.

I need to set an image datatype to NULL. objRS("field") = NULL works
for
datatypes int and varchar but not for datatype image, although there is
no
error - the image field still contains the image!

I'm using SQL server and running an UPDATE statement including image = NULL
works.

Any help would be much appreciated.
 
A

Aaron [SQL Server MVP]

Perhaps you could consider using upload to put the file on the file system,
and then running two separate update statements? There are ways to get
files into SQL Server without using an upload component. If you really have
to store the images in the database, that is. http://www.aspfaq.com/2149






Roger Withnell said:
I'm using AspUpload to upload two images at the same time. Don't see how I
can do that with an UPDATE, so I'm stuck with updating a record set.

Any other ideas appreciated.

Aaron said:
Use an UPDATE statement, then you don't have to worry about how the word
"null" is misinterpreted in the various layers.

conn.execute "UPDATE tbl SET imageCOLUMN = NULL [...where...]", , 129

--
http://www.aspfaq.com/
(Reverse address to reply.)




I'm updating a record by opening a recordset, setting the fields and the
updating it with objRS.Update.

I need to set an image datatype to NULL. objRS("field") = NULL works
for
datatypes int and varchar but not for datatype image, although there is
no
error - the image field still contains the image!

I'm using SQL server and running an UPDATE statement including image = NULL
works.

Any help would be much appreciated.
 
A

Aaron [SQL Server MVP]

Wait, let me understand.

Your form uploads two images, and sometimes you want to "clear" one or both
of them?

Can the ASP code determine whether one or both of these columns should
become NULL? Is there a reason why, AFTER the upload and affect of the
recordset, you can't run a separate UPDATE statement that sets the specific
images to NULL (not having anything to do with "updating a record set")?

--
http://www.aspfaq.com/
(Reverse address to reply.)




Roger Withnell said:
I'm using AspUpload to upload two images at the same time. Don't see how I
can do that with an UPDATE, so I'm stuck with updating a record set.

Any other ideas appreciated.

Aaron said:
Use an UPDATE statement, then you don't have to worry about how the word
"null" is misinterpreted in the various layers.

conn.execute "UPDATE tbl SET imageCOLUMN = NULL [...where...]", , 129

--
http://www.aspfaq.com/
(Reverse address to reply.)




I'm updating a record by opening a recordset, setting the fields and the
updating it with objRS.Update.

I need to set an image datatype to NULL. objRS("field") = NULL works
for
datatypes int and varchar but not for datatype image, although there is
no
error - the image field still contains the image!

I'm using SQL server and running an UPDATE statement including image = NULL
works.

Any help would be much appreciated.
 
R

Roger Withnell

Yes, I can run different SQL statements depending on whether new images are
uploaded or images are removed, when updating to NULL is required to remove
the existing images in the database table.

Seems odd that I can't set the image field to null via the recordset update
when I can do this with other datatypes. Is there a reason for this?

Aaron said:
Wait, let me understand.

Your form uploads two images, and sometimes you want to "clear" one or
both
of them?

Can the ASP code determine whether one or both of these columns should
become NULL? Is there a reason why, AFTER the upload and affect of the
recordset, you can't run a separate UPDATE statement that sets the
specific
images to NULL (not having anything to do with "updating a record set")?

--
http://www.aspfaq.com/
(Reverse address to reply.)




Roger Withnell said:
I'm using AspUpload to upload two images at the same time. Don't see how I
can do that with an UPDATE, so I'm stuck with updating a record set.

Any other ideas appreciated.

Aaron said:
Use an UPDATE statement, then you don't have to worry about how the
word
"null" is misinterpreted in the various layers.

conn.execute "UPDATE tbl SET imageCOLUMN = NULL [...where...]", , 129

--
http://www.aspfaq.com/
(Reverse address to reply.)




I'm updating a record by opening a recordset, setting the fields and the
updating it with objRS.Update.

I need to set an image datatype to NULL. objRS("field") = NULL works
for
datatypes int and varchar but not for datatype image, although there
is
no
error - the image field still contains the image!

I'm using SQL server and running an UPDATE statement including image =
NULL
works.

Any help would be much appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top