Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 969877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:42:57+00:00 2026-05-16T02:42:57+00:00

SERVER A: public string connStr = Data Source=PH-09-5336;Initial Catalog=InventoryDB;Integrated Security=True; SERVER B: public string

  • 0

SERVER A: public string connStr = “Data Source=PH-09-5336;Initial Catalog=InventoryDB;Integrated Security=True”;

SERVER B: public string connWIP = “Data Source=PWODU-COGNOSDB3;Initial Catalog=BI_SOURCE;

I have this method of inserting records to InventoryDB.DBO.FG_FILLIN from excell file.

Select records from BI_SOURCE.dbo.ODU_WIP_PI then update the null records(item Number) on InventoryDB.DBO.FG_FILLIN if its serialnumber is match on BI_SOURCE.dbo.ODU_WIP_PI serialnumber.

Problems:

I have tried to updated 13000 of records and it takes 5 minutes to be updated.
I need to update the new inserted record InventoryDB.DBO.FG_FILLIN that has only itemnumber that have null records.

But in my code it loops and update again all records in InventoryDB.DBO.FG_FILLIN

I really stack in this problem.

-------------------------------------INSERT RECORDS----------------------------------------

  using (SqlConnection conn = new SqlConnection(connStr))
                {
                    using (SqlCommand cmd = new SqlCommand("Insert into dbo.FG_FILLIN Select * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=" + filepath1 + ";HDR=YES','SELECT * FROM [" + Sheetname1 + "$]')", conn))
                    {


                        try
                        {
                            conn.Open();

                            cmd.ExecuteNonQuery();

                            txtsheet1.Text = string.Empty;
                            txtpath1.Text = string.Empty;
                            txtpath1.Focus();
                            MessageBox.Show("FILL IN Mass Upload Success!");


                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                            txtsheet1.Text = string.Empty;
                            txtpath1.Text = string.Empty;
                            txtpath1.Focus();
                        }
                        finally
                        {
                            if (conn.State == ConnectionState.Open) cmd.Connection.Close();
                            conn.Close();
                        }
                    }

---------------------------------SELECT UPDATE -----------------------------------

public void Update()
        {

            using (SqlConnection conn = new SqlConnection(connWIP))
            {
                try
                {

                    conn.Open();
                    using (SqlDataAdapter dAd = new SqlDataAdapter("select WIP_serialNumber, WIP_ItemID from BI_SOURCE.dbo.ODU_WIP_PI", conn))
                    {
                        DataTable data = new DataTable();
                        dAd.Fill(data);
                        using (SqlConnection conn2 = new SqlConnection(connStr))
                        {
                            conn2.Open();
                            try
                            {

                                foreach (DataRow recordFromServerA in data.Rows)
                                {

                                    using (SqlCommand dCmd = new SqlCommand("update [dbo].[FG_FILLIN] SET ItemNumber=@ItemNumber where SerialNumber=@SerialNumber", conn2))
                                    {


dCmd.Parameters.AddWithValue("@ItemNumber", recordFromServerA["WIP_ItemAlias"]);
                                                                               dCmd.Parameters.AddWithValue("@SerialNumber", recordFromServerA["WIP_serialNumber"]);
                                        dCmd.ExecuteNonQuery();
                                    }
                                }
                            }
                            catch (Exception ee)
                            {
                                MessageBox.Show(ee.Message);
                            }
                            finally
                            {
                                if (conn2.State == ConnectionState.Open) conn2.Close();
                            }


                        }


                    }
                    MessageBox.Show("All Records Updated Successfully!");

                }

                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message);
                }
                finally
                {
                    if (conn.State == ConnectionState.Open) conn.Close();
                }

            }
        }
        #endregion
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T02:42:57+00:00Added an answer on May 16, 2026 at 2:42 am

    If I’ve understood your problem correctly you might be able to speed up the update process considerably by just executing a single SQL statement, rather than looping through each row individually.

    How about this? After you’ve loaded your records into table A (FG_FILLIN), create an SQL UPDATE statement that uses a join from table A onto table B where the ItemNumber field in table A is null. Something like this should do it:

    UPDATE [dbo].[FG_FILLIN]
    SET ItemNumber = table2.WIP_ItemID
    FROM [dbo].[FG_FILLIN] INNER JOIN BI_SOURCE.dbo.ODU_WIP_PI as table2
    ON [dbo].[FG_FILLIN].SerialNumber = table2.WIP_SerialNumber
    WHERE [dbo].[FG_FILLIN].ItemNumber IS NULL
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 513k
  • Answers 513k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It can be done in the program, index only if… May 16, 2026 at 5:48 pm
  • Editorial Team
    Editorial Team added an answer glib is pretty nice because: liberally licensed (LGPL) constant development… May 16, 2026 at 5:48 pm
  • Editorial Team
    Editorial Team added an answer Assuming you're running PHP via mod_php (may not even matter)… May 16, 2026 at 5:48 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Using a connection string of Provider=SQLOLEDB;Data Source=localhost;User ID=foo;password=bar;Database=CodeLists;Pooling=true;Min Pool Size=20;Max Pool Size=30; I get
Using GWT I have a Java class: public class Pojo { private String name;
We are streaming data between a server (written in .Net running on Windows) to
I got some data inputed by the user that should be added to a
My program is now still running to import data from a log file into
I recently wrote a quick-and-dirty proof-of-concept proxy server in C# as part of an
How can I pass my client-side object to my server object in .net remoting?
We have an Adobe Flex client talking to a .NET server using WebORB. Simplifying
I'm getting following error when my client tries to connect to my server socket:
Problem: jQuery DataTables server-side processing using ASP.NET WebForms. Solution: Darin Dimitrov answered the question

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.