Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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
Comments
Hasham Ahmad at 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
good
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.
  Permalink  
Comments
chander_rani at 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 at 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 at 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 at 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)

  Print Answers RSS
0 Maciej Los 245
1 OriginalGriff 210
2 Manfred R. Bihy 190
3 CHill60 180
4 _Amy 155
0 OriginalGriff 7,445
1 Sergey Alexandrovich Kryukov 6,157
2 Maciej Los 3,774
3 Peter Leow 3,448
4 CHill60 2,702


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 8 Feb 2013
Copyright © CodeProject, 1999-2014
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