Click here to Skip to main content
13,446,174 members (36,616 online)
Rate this:
Please Sign up or sign in to vote.
See more:
i want to calculate total deleted records and delete particular record, like if user enter 'raj' in text box and after submitting a button page will transfer to another page and some information should be show on page that is total number of 'Raj' deleted and delete 'Raj' from a table. pls tell me how to do this problem with sql database...
Posted 8-Feb-13 7:15am
Hasham Ahmad 8-Feb-13 13:27pm
nothing to be done, just select the count before deleting and display it on the other page

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If you are using SQL ExecuteNonQuery [^] command to delete, the method returns how many rows affected for the last executed command.

if its a delete statement the return value is the how many rows deleted.
chander_rani 8-Feb-13 14:06pm
i need it in c#, i require total deleted records which have to show on page in lable, and the raj records should be delete from table
jibesh 8-Feb-13 14:14pm
can you explain the relation between the table. since you didnt show any code and you did not explain well I can only provide hints about your problem.

If you know how to execute the sql statement you would know how to get the record number.
as explained above, Construct a delete query using the textInput eg:

delete from table where field_name like'%inputtext'; this is pseudo code only
chander_rani 8-Feb-13 14:25pm
sir i can delete the records from table but i want to know that how to show total number of record deleted from a table, and one more thing i want to know that only single query can delete and calculate total deleted records from a table but how, and which query. pls tell me.
jibesh 8-Feb-13 14:31pm
have wrote any code for this delete operation? if yes can you paste it here. or check the sample below

string myExecuteQuery ="delete from your_tableName where yourfieldName='%inoput";

SqlCommand myCommand = new SqlCommand(myExecuteQuery, myConnection);
int count = myCommand.ExecuteNonQuery();

variable count holds the number of records deleted for the above delete query. give a try and tell me the can use this count to display total number records deleted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02-2016 | 2.8.180314.2 | Last Updated 8 Feb 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100