Identifying the failed records??? [modified]
-
hai, here i am updating 100 records at the same time. when the update fails, the record is to store in a log file (.txt). how to implement.? FOR EXAMPLE............. try { for (i=1;i=5;i++) { int a=i; sqlinsert="update tbl_name set loop_no=a where rollnumber=a"; cmd = new SqlCommand(sqlinsert, conn); } } catch(SqlException ae) { strreturn += "<br>Message: " + ae.Message.ToString(); } How to capture the failure records for the above UPDATE statement? HELP ME! i m using ASP.NET with C# (.net 2005, 2.0 framework)
modified on Wednesday, April 16, 2008 8:40 AM
-
hai, here i am updating 100 records at the same time. when the update fails, the record is to store in a log file (.txt). how to implement.? FOR EXAMPLE............. try { for (i=1;i=5;i++) { int a=i; sqlinsert="update tbl_name set loop_no=a where rollnumber=a"; cmd = new SqlCommand(sqlinsert, conn); } } catch(SqlException ae) { strreturn += "<br>Message: " + ae.Message.ToString(); } How to capture the failure records for the above UPDATE statement? HELP ME! i m using ASP.NET with C# (.net 2005, 2.0 framework)
modified on Wednesday, April 16, 2008 8:40 AM
Hi John Sundar, In the try block yau have a statement try { cmd.ExecuteNonQuery(); } Catch(Exception ex) { // In the catch block write file streams to write the file and in the file write roll no which not updated. }
-
Hi John Sundar, In the try block yau have a statement try { cmd.ExecuteNonQuery(); } Catch(Exception ex) { // In the catch block write file streams to write the file and in the file write roll no which not updated. }
could u provide me an example senthil? for my QUESTION?
-
could u provide me an example senthil? for my QUESTION?
After You enter try { cmd.ExecuteNonQuery(); } catch(Exception ex) { FileStream fs; StreamWriter sw; fs = new FileStream("practice.txt", FileMode.Open ); sw = new StreamWriter(fs); // write a line to the file //In this line you concatenate the data string newLine = "Not so different from you and me"; sw.WriteLine(newLine); // close the streams sw.Close(); fs.Close(); }
-
After You enter try { cmd.ExecuteNonQuery(); } catch(Exception ex) { FileStream fs; StreamWriter sw; fs = new FileStream("practice.txt", FileMode.Open ); sw = new StreamWriter(fs); // write a line to the file //In this line you concatenate the data string newLine = "Not so different from you and me"; sw.WriteLine(newLine); // close the streams sw.Close(); fs.Close(); }
try { cmd.ExecuteNonQuery(); } catch(Exception ex) { FileStream fs; StreamWriter sw; fs = new FileStream("practice.txt", FileMode.Open ); sw = new StreamWriter(fs); // write a line to the file //In this line you concatenate the data string newLine = "Not so different from you and me"; sw.WriteLine(newLine); // close the streams sw.Close(); fs.Close(); } -----> i dont want to store a single line in the practice.txt. i need to store the record values which is failed (i.e.. 100,200) as mentioned in my example....... How to achieve it? thanks in advance
-
try { cmd.ExecuteNonQuery(); } catch(Exception ex) { FileStream fs; StreamWriter sw; fs = new FileStream("practice.txt", FileMode.Open ); sw = new StreamWriter(fs); // write a line to the file //In this line you concatenate the data string newLine = "Not so different from you and me"; sw.WriteLine(newLine); // close the streams sw.Close(); fs.Close(); } -----> i dont want to store a single line in the practice.txt. i need to store the record values which is failed (i.e.. 100,200) as mentioned in my example....... How to achieve it? thanks in advance
Whether you are entering the values in the textboxes(Roll No) for updating the records.
-
Whether you are entering the values in the textboxes(Roll No) for updating the records.
no senthil, i m taking those roll numbers from an excel file and processing.... i will pass the roll number one by one. when it failed, i want to store it........ how to achieve it?
-
no senthil, i m taking those roll numbers from an excel file and processing.... i will pass the roll number one by one. when it failed, i want to store it........ how to achieve it?
How will you take from excel file can you send me the code?
-
How will you take from excel file can you send me the code?
hai, here i am updating 100 records at the same time. when the update fails, the record is to store in a log file (.txt). how to implement.? FOR EXAMPLE............. try { for (i=1;i=5;i++) { int a=i; sqlinsert="update tbl_name set loop_no=a where rollnumber=a"; cmd = new SqlCommand(sqlinsert, conn); } } catch(SqlException ae) { strreturn += "<br>Message: " + ae.Message.ToString(); } How to capture the failure records for the above UPDATE statement? HELP ME! i m using ASP.NET with C# (.net 2005, 2.0 framework)
-
hai, here i am updating 100 records at the same time. when the update fails, the record is to store in a log file (.txt). how to implement.? FOR EXAMPLE............. try { for (i=1;i=5;i++) { int a=i; sqlinsert="update tbl_name set loop_no=a where rollnumber=a"; cmd = new SqlCommand(sqlinsert, conn); } } catch(SqlException ae) { strreturn += "<br>Message: " + ae.Message.ToString(); } How to capture the failure records for the above UPDATE statement? HELP ME! i m using ASP.NET with C# (.net 2005, 2.0 framework)
-
hai, here i am updating 100 records at the same time. when the update fails, the record is to store in a log file (.txt). how to implement.? FOR EXAMPLE............. try { for (i=1;i=5;i++) { int a=i; sqlinsert="update tbl_name set loop_no=a where rollnumber=a"; cmd = new SqlCommand(sqlinsert, conn); } } catch(SqlException ae) { strreturn += "<br>Message: " + ae.Message.ToString(); } How to capture the failure records for the above UPDATE statement? HELP ME! i m using ASP.NET with C# (.net 2005, 2.0 framework)
for (i=1;i=5;i++) { int a=i; sqlinsert="update tbl_name set loop_no=a where rollnumber=a"; cmd = new SqlCommand(sqlinsert, conn); try { cmd.ExecuteNonQuery(); } catch(Exception ex) { FileStream fs; StreamWriter sw; fs=new Filestream("logfile.txt",FileMode.open); sw=new StreamWriter(fs); string newline="Roll No:"+a+"was not updated"; sw.close(); fs.close(); } } I think you understand, if you have any doubt ask me.
-
for (i=1;i=5;i++) { int a=i; sqlinsert="update tbl_name set loop_no=a where rollnumber=a"; cmd = new SqlCommand(sqlinsert, conn); try { cmd.ExecuteNonQuery(); } catch(Exception ex) { FileStream fs; StreamWriter sw; fs=new Filestream("logfile.txt",FileMode.open); sw=new StreamWriter(fs); string newline="Roll No:"+a+"was not updated"; sw.close(); fs.close(); } } I think you understand, if you have any doubt ask me.
once if its go for "CATCH" block, how it can proceed others? i.e, if record 2 fails, will it proceed other records and complete the whole FOR loop???? i tried.. but getting error... how to achieve it? thanks in advance and understanding....