Deleting records in database ONLY for a specific field and NOT the whole row

speed

Member
Joined
Apr 4, 2007
Messages
7
Programming Experience
Beginner
I am a newbie in vb. I am wondering..is it possible to Delete records in the database (the database that I use is Microsoft Access and has only two fields which are 'ID' and 'Picture') ONLY for a specific field and NOT the whole row.

For example, I understand that, the code as below...

Dim sql As String = "Delete From enroll where ID = 1"

....will delete the whole row with ID = 1 (both the Picture and ID field will be deleted).

So, what should be the code if I want it to delete ONLY the data in the Picture field where ID= 1 (without deleting the ID field). Is it possible? I hope you guys can help me. I really appreciate it.
 
You can't delete a field, all you can do is change it's value. (Deleting the field in a table deletes it in all records)

UPDATE enroll SET Picture='' WHERE ID = 1;

or perhaps

UPDATE enroll SET Picture=NULL WHERE ID = 1;
 
www.w3schools.com and see their SQL sections..

ps; Cylindric, how can you be certain that the Picture field is a string? Setting it to an empty string might not work.. try:

UPDATE enrol SET picture = NULL WHERE ID = 1
 
You know.. i never even noticed the second SQL you posted.

<-- Bozo!

Sorry about that!
 
Back
Top