Click here to Skip to main content
14,869,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
My DataTable contains more than two Lakh records, i am trying to insert all records in sql server table, it insert all record successfully but doesn't show final message to user that all records added successfully,
please someone help me what should i do
Posted
Comments
OriginalGriff 11-Aug-11 4:30am
   
Show us the relevant code fragment!
sujit0761 11-Aug-11 4:37am
   
Please put the code , you are using.
Herman<T>.Instance 11-Aug-11 4:37am
   
what is 'two Lakh records' ?
Syed Salman Raza Zaidi 11-Aug-11 4:43am
   
two lakhs means two hundre thousand

use this

C#
 private SqlCommand objCommand;



if (objCommand.ExecuteNonQuery() > 0)
           {
               return "SUCCESS : Record has been inserted";
           }
           else
           {
               return "ERROR : SQL Exception";
           }
   
Comments
lw@zi 11-Aug-11 4:49am
   
This will not work if OP is using stored procedure.
Herman<T>.Instance 11-Aug-11 5:10am
   
and what is the nocount setting? http://msdn.microsoft.com/en-us/library/aa259204(v=sql.80).aspx
lw@zi 11-Aug-11 6:44am
   
It will not tell the number of rows that were affected by your query.
If no exception happens in while calling ExecuteNonQuery, consider the insert as successfull. Of course you will have to make sure that the stored procedure (if any) does not hides any exception.
   

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