search and delete in vb.net 2003

5 pts.
Tags:
VB.NET
VB.NET 2003
hi, i have a select query in .net dim sqlstr as string sqlstr=select access_id from emp_main where emp_no=98198 and then if i get access id as 5 i want to delete tht whole record from emp_main table
ASKED: April 13, 2009  5:18 PM
UPDATED: April 14, 2009  3:43 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

<b>delete from emp_main where access_id=5</b>

———–

The above command will delete <b>all records </b>having access_id=5.

You should use something similar to this:

<pre>DELETE FROM emp_main WHERE emp_no = 98198</pre>

On the other hand, if you are executing the SELECT just to determine if the record must be deleted, you could avoid it, and execute a DELETE command with both conditions:

<pre>DELETE FROM emp_main WHERE emp_no = 98198 AND access_id = 5</pre>

This way, if the record has an access_id different from 5, it won’t be deleted.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following