By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,925 Members | 1,847 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,925 IT Pros & Developers. It's quick & easy.

DeleteCommand.executenonquery with ADO.NET - How do I know if a record was deleted?

P: n/a
After entering the sql statement da.deletecommand.commandtext = "Delete from
Users where username = @username" I set the parameter to the username I wish
to delete.

This successfully deletes the user. However, even if I enter an non-existant
user, I cannot discern whether a user was deleted or not. Is there a way to
do this? (I would rather not use a dataset, since I am trying to increase
performance).

thanks in advance

Rodger Dusatko
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Rodger Dusatko" <ro****@dusatko.com> schrieb
After entering the sql statement da.deletecommand.commandtext =
"Delete from Users where username = @username" I set the parameter to
the username I wish to delete.

This successfully deletes the user. However, even if I enter an
non-existant user, I cannot discern whether a user was deleted or
not. Is there a way to do this? (I would rather not use a dataset,
since I am trying to increase performance).


There's an ADO.Net group for ADO.Net related questions:
microsoft.public.dotnet.framework.adonet
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2

P: n/a
Hi Rodger,

Then you want only to do deletecommands, have than a look at the normal
command executecommands

http://msdn.microsoft.com/library/de...querytopic.asp

When you have more questions about that I advice you as well to ask it in
the newsgroup Armin did pointed you on.

Cor
Nov 20 '05 #3

P: n/a
Rodger,
Have you looked at the return value from ExecuteNonQuery, it returns the #
of rows affected.

Something like (untested):
Dim deleteCommand As SqlCommand

If deleteCommand.ExecuteNonEquery() = 0 then
MessageBox.Show "User not Deleted"
End If

Hope this helps
Jay

"Rodger Dusatko" <ro****@dusatko.com> wrote in message
news:c9*************@news.t-online.com...
After entering the sql statement da.deletecommand.commandtext = "Delete from Users where username = @username" I set the parameter to the username I wish to delete.

This successfully deletes the user. However, even if I enter an non-existant user, I cannot discern whether a user was deleted or not. Is there a way to do this? (I would rather not use a dataset, since I am trying to increase
performance).

thanks in advance

Rodger Dusatko

Nov 20 '05 #4

P: n/a
Thanks! That was the answer.
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> schrieb im
Newsbeitrag news:eA**************@TK2MSFTNGP12.phx.gbl...
Rodger,
Have you looked at the return value from ExecuteNonQuery, it returns the #
of rows affected.

Something like (untested):
Dim deleteCommand As SqlCommand

If deleteCommand.ExecuteNonEquery() = 0 then
MessageBox.Show "User not Deleted"
End If

Hope this helps
Jay

"Rodger Dusatko" <ro****@dusatko.com> wrote in message
news:c9*************@news.t-online.com...
After entering the sql statement da.deletecommand.commandtext = "Delete

from
Users where username = @username" I set the parameter to the username I

wish
to delete.

This successfully deletes the user. However, even if I enter an

non-existant
user, I cannot discern whether a user was deleted or not. Is there a way

to
do this? (I would rather not use a dataset, since I am trying to increase performance).

thanks in advance

Rodger Dusatko


Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.