Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Comments
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

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.
 
Share this answer
 
Comments
[no name] 8-Feb-13 14:06pm    
i need it in asp.net 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
[no name] 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);
myCommand.Connection.Open();
int count = myCommand.ExecuteNonQuery();
myConnection.Close();

variable count holds the number of records deleted for the above delete query. give a try and tell me the answer.you 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900