C# framework 3.5 :SQL Server 2000: SqlBulkCopy:WriteToServer: What happening while another process is executing on database?

Posted on 2009-12-16
Last Modified: 2013-12-17
I have an  sql server 2000 database.

I execute the following code:

SqlConnection conn_1 = null;

  conn_1 = new SqlConnection(_conn.ConnectionString);
                string str_ColumnTable;

                str_ColumnTable = string.Format("Columns_{0}", 1);
                if (conn_1.State == ConnectionState.Closed)

                using (SqlBulkCopy bcp = new SqlBulkCopy(conn_1))
                    bcp.DestinationTableName = str_ColumnTable;



I have also another application that deletes old records on the same database table on specific time.
I have the following question:
If the "delete"  application Starts, and on the same time the other application executes the specific code (...bcp.WriteToServer...), what happening?
By the way The delete operation has connection Time out 1800 seconds (on its connection string).
Yesterday I remark this:
First I delete records manually.
While deleting the records, the other program  executes  bcp.WriteToServer....
I have a record counter on interface of inserting program.I expect to put 500 records .
And the counter is stuck  in 8.I  was waiting for few seconds and then the application puts the rest 492 records.
I remark that on the same time the delete operation is complete.
So , if Delete operation is occur for example 20 minutes, can   bcp.WriteToServer --> wait for this time?
I read the opposite case:if    bcp.WriteToServer happens then no other operations happens concurrently.
But on specific case:  bcp.WriteToServer  puts  8 records -------wait deleting from another process--- complete  bcp.WriteToServer.
Could you please give some advices?

with regards ,
Question by:nikavak
    LVL 7

    Accepted Solution

    You can lock the table(s) but that may (and probably will) create deadlock problems.

    Author Closing Comment


    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
    Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now