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

  • SEARCH
  • Home
  • 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

Related Questions

I have a method to insert data into server like this: public void doInsert(){
I'm using RSA private-public key encryption to encrypt data coming from server. The main
I'm using this code for downloading image from server: public Bitmap getBitmap(String path){ URL
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
this is my boost::asio server class Server: public boost::enable_shared_from_this<Server>, private boost::noncopyable{ private: boost::asio::ip::tcp::acceptor _acceptor;
I was trying to setup remote jmeter server and jmeter client. Server public IP
Pyzor uses UDP/IP as the communication protocol. We recently switched the public server to
I have the following methods on the server (RIA services): public IQueryable<Customer> GetCustomers() {
Is there an equivalent in dbg/cocoa/apple word for the Microsoft public symbol server and
This is my thread: public void run() { Log.d(ConnectionThread,Starting Server Connection); try { while(isThereActivityRunning())

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.