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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:28:56+00:00 2026-05-25T18:28:56+00:00

Is this the Correct way of Coding…?? its Working 100% fine.. But How Do

  • 0

Is this the Correct way of Coding…?? its Working 100%
fine.. But How Do i Shorten some more so that it looks nice….

and how do i check the Condition that….. if “REGID is already
present in table it should not add that column it should update the
column….

if (DSDBMax.Tables[0].Rows.Count > 0)
{


       for (int i = 0; i < DSDBMax.Tables[0].Rows.Count; i++)
       {
                DataAccess.Command cmdInsert = new Oca.DataAccess.Command();
                cmdInsert.CommandType = System.Data.CommandType.Text;
                cmdInsert.CommandString = "INSERT INTO STATUS (RigID,RigName,GroundDistance,DrillingSupervisor,DrillingEngineer,GeoSteering,Directional,MudCompany,OHLogs,JobIDRec,County,Area,WellName,Slot_Conductor,SurfaceLegalLocation,LocationType,State_Province,SurfaceLocation_Slot,Field,ReserveCategory,JOA,Well_Type,Land_Expiration,WI,NRI,Drilling_Permit,Unit_AlternateApproval,AFE,c_CALLS,c_STKD,c_WL,c_PLAT,c_DP,c_GP,c_DRILLPROG,c_SIMOPS,c_LOC,c_PMT,c_UNITAPP,c_AFE,c_TITLE) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
                //DataSet DsInsert = DataAccess.GetDataSet(dCorpID, cmdInsert);
                // DataAccess.ExecuteNonQuery(dCorpID, cmdInsert);
                cmdInsert.AddParameter("RigID",DSDBMax.Tables[0].Rows[i][0].ToString(), ParameterDirection.Input);
                cmdInsert.AddParameter("RigName",DSDBMax.Tables[0].Rows[i][1].ToString(), ParameterDirection.Input);
                cmdInsert.AddParameter("GroundDistance",DSDBMax.Tables[0].Rows[i][2].ToString(), ParameterDirection.Input);
                cmdInsert.AddParameter("DrillingSupervisor",DSDBMax.Tables[0].Rows[i][3].ToString(), ParameterDirection.Input);
                cmdInsert.AddParameter("DrillingEngineer", DSDBMax.Tables[0].Rows[i][4].ToString(), ParameterDirection.Input);
                cmdInsert.AddParameter("GeoSteering", DSDBMax.Tables[0].Rows[i][5].ToString(), ParameterDirection.Input);
                cmdInsert.AddParameter("Directional", DSDBMax.Tables[0].Rows[i][6].ToString(), ParameterDirection.Input);
                 cmdInsert.AddParameter("MudCompany", DSDBMax.Tables[0].Rows[i][7].ToString(), ParameterDirection.Input);
                 cmdInsert.AddParameter("OHLogs", DSDBMax.Tables[0].Rows[i][8].ToString(), ParameterDirection.Input);
                 cmdInsert.AddParameter("JobIDRec", DSDBMax.Tables[0].Rows[i][9].ToString(), ParameterDirection.Input);
                 cmdInsert.AddParameter("County", DSDBMax.Tables[0].Rows[i][10].ToString(), ParameterDirection.Input);
                 cmdInsert.AddParameter("Area", DSDBMax.Tables[0].Rows[i][11].ToString(), ParameterDirection.Input);
                  cmdInsert.AddParameter("WellName", DSDBMax.Tables[0].Rows[i][12].ToString(), ParameterDirection.Input);
                  cmdInsert.AddParameter("Slot_Conductor", DSDBMax.Tables[0].Rows[i][13].ToString(), ParameterDirection.Input);
                  cmdInsert.AddParameter("SurfaceLegalLocation", DSDBMax.Tables[0].Rows[i][14].ToString(), ParameterDirection.Input);
                  cmdInsert.AddParameter("LocationType", DSDBMax.Tables[0].Rows[i][15].ToString(), ParameterDirection.Input);
                  cmdInsert.AddParameter("State_Province", DSDBMax.Tables[0].Rows[i][16].ToString(), ParameterDirection.Input);
                  cmdInsert.AddParameter("SurfaceLocation_Slot", DSDBMax.Tables[0].Rows[i][17].ToString(), ParameterDirection.Input);
                  cmdInsert.AddParameter("Field", DSDBMax.Tables[0].Rows[i][18].ToString(), ParameterDirection.Input);
                  cmdInsert.AddParameter("ReserveCategory", DSDBMax.Tables[0].Rows[i][19].ToString(), ParameterDirection.Input);
                  cmdInsert.AddParameter("JOA", DSDBMax.Tables[0].Rows[i][20].ToString(), ParameterDirection.Input);                                  
                  cmdInsert.AddParameter("Well_Type", DSDBMax.Tables[0].Rows[i][21].ToString(), ParameterDirection.Input);
                  cmdInsert.AddParameter("Land_Expiration", DSDBMax.Tables[0].Rows[i][22].ToString(), ParameterDirection.Input);
                  cmdInsert.AddParameter("WI", DSDBMax.Tables[0].Rows[i][23].ToString(), ParameterDirection.Input);
                   cmdInsert.AddParameter("NRI", DSDBMax.Tables[0].Rows[i][24].ToString(), ParameterDirection.Input);
                    cmdInsert.AddParameter("Drilling_Permit", DSDBMax.Tables[0].Rows[i][25].ToString(), ParameterDirection.Input);
                    cmdInsert.AddParameter("Unit_AlternateApproval", DSDBMax.Tables[0].Rows[i][26].ToString(), ParameterDirection.Input);
                    cmdInsert.AddParameter("AFE", DSDBMax.Tables[0].Rows[i][27].ToString(), ParameterDirection.Input);
                     cmdInsert.AddParameter("c_CALLS", DSDBMax.Tables[0].Rows[i][28].ToString(), ParameterDirection.Input);
                     cmdInsert.AddParameter("c_STKD", DSDBMax.Tables[0].Rows[i][29].ToString(), ParameterDirection.Input);
                      cmdInsert.AddParameter("c_WL", DSDBMax.Tables[0].Rows[i][30].ToString(), ParameterDirection.Input);
                     cmdInsert.AddParameter("c_PLAT", DSDBMax.Tables[0].Rows[i][31].ToString(), ParameterDirection.Input);
                     cmdInsert.AddParameter("c_DP", DSDBMax.Tables[0].Rows[i][32].ToString(), ParameterDirection.Input);
                     cmdInsert.AddParameter("c_GP", DSDBMax.Tables[0].Rows[i][33].ToString(), ParameterDirection.Input);
                     cmdInsert.AddParameter("c_DRILLPROG", DSDBMax.Tables[0].Rows[i][34].ToString(), ParameterDirection.Input);
                     cmdInsert.AddParameter("c_SIMOPS", DSDBMax.Tables[0].Rows[i][35].ToString(), ParameterDirection.Input);
                     cmdInsert.AddParameter("c_LOC", DSDBMax.Tables[0].Rows[i][36].ToString(), ParameterDirection.Input);
                    cmdInsert.AddParameter("c_PMT", DSDBMax.Tables[0].Rows[i][37].ToString(), ParameterDirection.Input);
                    cmdInsert.AddParameter("c_UNITAPP", DSDBMax.Tables[0].Rows[i][38].ToString(), ParameterDirection.Input);
                    cmdInsert.AddParameter("c_AFE", DSDBMax.Tables[0].Rows[i][39].ToString(), ParameterDirection.Input);
                   cmdInsert.AddParameter("c_TITLE", DSDBMax.Tables[0].Rows[i][40].ToString(), ParameterDirection.Input);

                   DataAccess.ExecuteNonQuery(dCorpID, cmdInsert);




                    }
  • 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-25T18:28:57+00:00Added an answer on May 25, 2026 at 6:28 pm

    I would use a SqlBulkCopy() and column mapping if I were you.

    Something like:

     using (SqlBulkCopy copy = new SqlBulkCopy(
       {   
                    copy.ColumnMappings.Add("dtcolumnname", "sqlcolumnname");
    
    
            copy.DestinationTableName = "TABLE";
            copy.WriteToServer(table);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Would this be the correct way of declaring that an XML element Cluster contains
This may not be the correct way to use controllers, but I did notice
Is this the correct way to do it? <a id=load href=# class=btn load onclick=request(this);
Is this the correct way to obtain the most negative double in Java? double
Is this the correct way to pass two ids in jQuery? I am having
Is this the correct way to update a ProgressBar when playing Media? I figured
This is a simple question: Is this a correct way to get an integer
I'm not sure if this is the correct way to synchronize my ArrayList .
I'm still not sure this is the correct way to go about this, maybe
What is the correct way to do this? For example, how would I change

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.