Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Identifying the failed records??? [modified]

Identifying the failed records??? [modified]

Scheduled Pinned Locked Moved ASP.NET
csharptutorialasp-nethelpquestion
12 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S senthilsstil

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

    J Offline
    J Offline
    John Sundar
    wrote on last edited by
    #3

    could u provide me an example senthil? for my QUESTION?

    S 1 Reply Last reply
    0
    • J John Sundar

      could u provide me an example senthil? for my QUESTION?

      S Offline
      S Offline
      senthilsstil
      wrote on last edited by
      #4

      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(); }

      J 1 Reply Last reply
      0
      • S senthilsstil

        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(); }

        J Offline
        J Offline
        John Sundar
        wrote on last edited by
        #5

        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

        S 1 Reply Last reply
        0
        • J John Sundar

          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

          S Offline
          S Offline
          senthilsstil
          wrote on last edited by
          #6

          Whether you are entering the values in the textboxes(Roll No) for updating the records.

          J 1 Reply Last reply
          0
          • S senthilsstil

            Whether you are entering the values in the textboxes(Roll No) for updating the records.

            J Offline
            J Offline
            John Sundar
            wrote on last edited by
            #7

            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?

            S 1 Reply Last reply
            0
            • J John Sundar

              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?

              S Offline
              S Offline
              senthilsstil
              wrote on last edited by
              #8

              How will you take from excel file can you send me the code?

              J 1 Reply Last reply
              0
              • S senthilsstil

                How will you take from excel file can you send me the code?

                J Offline
                J Offline
                John Sundar
                wrote on last edited by
                #9

                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)

                S V 2 Replies Last reply
                0
                • J John Sundar

                  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)

                  V Offline
                  V Offline
                  Vijayitsb
                  wrote on last edited by
                  #10

                  Hi, You can use this logic. I hope that this may help you int b = 0; string ew; for (int i = 0; i <= 5; i++) { try { if(b==i) ew=Session["Good"].ToString(); Response.Write("pass" + i); } catch { Response.Write("Failed" + i); } }

                  Cheers..! Vijay s

                  1 Reply Last reply
                  0
                  • J John Sundar

                    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)

                    S Offline
                    S Offline
                    senthilsstil
                    wrote on last edited by
                    #11

                    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.

                    J 1 Reply Last reply
                    0
                    • S senthilsstil

                      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.

                      J Offline
                      J Offline
                      John Sundar
                      wrote on last edited by
                      #12

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

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups