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 509111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:58:37+00:00 2026-05-13T06:58:37+00:00

We have a third party application that accept calls using an XML RPC mechanism

  • 0

We have a third party application that accept calls using an XML RPC mechanism for calling stored procs.

We send a ZIP-compressed dataset containing multiple tables with a bunch of update/delete/insert using this mechanism. On the other end, a CLR sproc decompress the data and gets the dataset.

Then, the following code gets executed:

    using (var conn = new SqlConnection("context connection=true"))
    {
        if (conn.State == ConnectionState.Closed)
           conn.Open();

        try
        {
            foreach (DataTable table in ds.Tables)
            {
                string columnList = "";
                for (int i = 0; i < table.Columns.Count; i++)
                {
                    if (i == 0)
                        columnList = table.Columns[0].ColumnName;
                    else
                        columnList += "," + table.Columns[i].ColumnName;
                }

                var da = new SqlDataAdapter("SELECT " + columnList + " FROM " + table.TableName, conn);

                var builder = new SqlCommandBuilder(da);
                builder.ConflictOption = ConflictOption.OverwriteChanges;

                da.RowUpdating += onUpdatingRow;
                da.Update(ds, table.TableName);

            }
        }

        catch (....)
        {
           .....
        }
    }

Here’s the event handler for the RowUpdating event:

public static void onUpdatingRow(object sender, SqlRowUpdatingEventArgs e)
{
    if ((e.StatementType == StatementType.Update) && (e.Command == null))
    {
        e.Command = CreateUpdateCommand(e.Row, sender as SqlDataAdapter);
        e.Status = UpdateStatus.Continue;
    }
}

and the CreateUpdateCommand method:

private static SqlCommand CreateUpdateCommand(DataRow row, SqlDataAdapter da)
{
    string whereClause = "";
    string setClause = "";

    SqlConnection conn = da.SelectCommand.Connection;
    for (int i = 0; i < row.Table.Columns.Count; i++)
    {
        char quoted;

        if ((row.Table.Columns[i].DataType == Type.GetType("System.String")) ||
            (row.Table.Columns[i].DataType == Type.GetType("System.DateTime")))
            quoted = '\'';
        else
            quoted = ' ';

        string val = row[i].ToString();
        if (row.Table.Columns[i].DataType == Type.GetType("System.Boolean"))
            val = (bool)row[i] ? "1" : "0";

        bool isPrimaryKey = false;

        for (int j = 0; j < row.Table.PrimaryKey.Length; j++)
        {
            if (row.Table.PrimaryKey[j].ColumnName == row.Table.Columns[i].ColumnName)
            {
                if (whereClause != "")
                    whereClause += " AND ";
                if (row[i] == DBNull.Value)
                    whereClause += row.Table.Columns[i].ColumnName + "=NULL";
                else
                    whereClause += row.Table.Columns[i].ColumnName + "=" + quoted +
                                   val + quoted;
                isPrimaryKey = true;
                break;
            }
        }

        /* Only values for column that is not a primary key can be modified  */
        if (!isPrimaryKey)
        {
            if (setClause != "")
                setClause += ", ";

            if (row[i] == DBNull.Value)
                setClause += row.Table.Columns[i].ColumnName + "=NULL";
            else
                setClause += row.Table.Columns[i].ColumnName + "=" + quoted +
                             val + quoted;

        }
    }

    return new SqlCommand("UPDATE " + row.Table.TableName + " SET " + setClause + " WHERE " + whereClause, conn);
}

However, this is really slow when we have a lot of records.

Is there a way to optimize this or an entirely different way to send lots of udpate/delete on several tables? I would really much like to use TSQL for this but can’t figure a way to send a dataset to a regular sproc.

Additional notes:

  • We cannot directly access the SQLServer database.
  • We tried without compression and it was slower.
  • 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-13T06:58:37+00:00Added an answer on May 13, 2026 at 6:58 am

    If you’re using SQL Server 2008, you should look into MERGE

    Look here for more info on MERGE

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to create a user in a third party application that stores its
I am building an android application that uses several third party libraries. I have
We have a third party application that provied its web services to us by
I have a MySQL table from a third-party application that has millions of rows
I have written an application that use a third party library. I have then
I have a third party application that requires a 'POP 3 connection string'. I'd
I have an application that I am writting that communicates with a third-party program
I have an application that's been provided by a third party. The only means
We have a Windows Forms application that uses a (third party) ActiveX control, and
I have a third-party application that's extensible by adding exe-files that perform dataconversion etc.

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.