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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:30:50+00:00 2026-06-12T15:30:50+00:00

This program was already written and I need to add to it an update

  • 0

This program was already written and I need to add to it an update SQL statement to update another table based on @IN. After declaring the SQL command how do I get it to excute, can I use the same SQLConnection as other sql command? WHat this program does is it parses in a file to a list called individuals and from that I just want to update the fields in SQL. The first SQL was already written in an seems to execute correctly now I need to do the UpdtHasInv SQL and actually get the code to perform the update is where I need help.

Heres what I have so far:

 static void InsertCustomData(Collection<Individuals> individuals)
    {
        #region
        string insertsql = "";

        insertsql = @"Insert into IND (IND_ID, ITEM_NAME,   INDL_ITEM_VALUE, XPTIM)
                        select  IND_ID, '{0}' as Item, '{1}' as val, (current timestamp -      curtime)"
                        FROM    IND 
                        where   IN = @IN";

    // this is SQL I added for update
          **UpdtHasInv = @"UPDATE Ind
                       SET    HAS_I = -1
                       WHERE  IN = @IN";**

        #endregion

        using (DB2Connection conn = DB2Helper.getConnection())
        {
            DB2Command cmd = conn.CreateCommand();                
            cmd.CommandTimeout = 600;
            cmd.Parameters.Add("@IN", "");

            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }

            foreach (Individuals individual in individuals)
            {
                cmd.Parameters["@IN"].Value = individual.In;


                foreach (CustomData customData in individual.CustomData)
                {
                    cmd.CommandText = string.Format(insertIndsql,   customData.Data.Key,            customData.Data.Value);  

Could I just write : ‘cmd.CommandText = UpdtIsInv;’ after these lines:

 foreach (Individuals individual in individuals)
            {
                cmd.Parameters["@IN"].Value = individual.in
  • 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-06-12T15:30:52+00:00Added an answer on June 12, 2026 at 3:30 pm

    You could simply append your UPDATE after the INSERT using a semicolon.

    insertIndsql = @"
    INSERT INTO IND (IND_ID, ITEM_NAME,   INDL_ITEM_VALUE, XPTIMESTAMP)
    SELECT  INDIVIDUAL_ID, '{0}' as Item, '{1}' as val, (current timestamp - curtime)
    FROM    IND 
    WHERE   TIN = @TIN;
    
    UPDATE DB2INST1.Individual
    SET    HAS_INVESTMENT = -1
    WHERE  TIN = @TIN;";
    

    When executed, both statements will be executed as part of the same command.

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

Sidebar

Related Questions

I need an input box in a UI program that is already written derived
I saw this: Detecting if a program is already installed with NSIS . I
This program builds a dictionary out of a list based on what two index
this program is for class to display the database in Listview.i want to add
I've written a simple program in C++ using OpenGL. What I need is to
I am designing an installer interface for a already written program. It is my
I'm creating a C# program and I need to control another application. I found
received help with. Basically, this code is written in Java but I need it
This program returns: package main import ( flag fmt ) func main() { num_agents
This program runs just fine, but for some reason when I ask for an

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.