You must Sign In to post a response.
  • Category: .NET

    Prevent Data Loss While Sudden Power Cut (Where inserting Data via DataGridView)

    Hi,

    I am working with C# windows application along with DataGridView. I want to insert the data for each 10 records into database. I faced the data lost before inserting the data into database due to sudden power cut. So how can I prevent it.... how can i store the data temporary in somewhere before inserting into Database.
  • #768857
    Hi,

    Nice question, I'm not pretty sure about this but as per my experience I will say something.

    Here I have one question you are asking to store the data in temporary location, what happens if the power cuts while storing it in temporary location?

    So, my suggestion is if you are using sql as a backend then use Transactions like COMMIT & ROLLBACK transactions, using commit your record successfully saved it in database if any interruption you can use rollback.


    BEGIN Transaction
    COMMIT Transaction
    ROLLBACK Transaction


    Hope this helps you...

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #768858
    Hi Naveen,

    We can use the local drive for temporary location. And, i don't want to go back with database for every record. Inserting records with 10 rows as each time in database from datagridview.

  • #768859
    Hi Gopi,

    In that case write the each record in to one csv file and whenever you want to insert into database then use that csv and insert it into database.

    If you want to know how to read & write in csv refer below link here I explained clearly how to achieve this task..

    dotnetspider.com/resources/46438-Read-and-Write-CSV-in-C.aspx

    Hope this helps you...

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


Sign In to post your comments