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
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

 private SqlCommand objCommand;

if (objCommand.ExecuteNonQuery() > 0)
               return "SUCCESS : Record has been inserted";
               return "ERROR : SQL Exception";
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?
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