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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:52:15+00:00 2026-06-17T16:52:15+00:00

I am attempting to dynamically update a set of database tables. I have two

  • 0

I am attempting to dynamically update a set of database tables. I have two variables;
table_name & field_name. These are populated by a foreach loop, that loops through a DataTable. Everytime we hit a new row in the DataTable the names change respectively. Within this loop I create a new Oracle Connection and attempt to write an update with the current table_name/field_name. But Oracle keeps giving me an error on my ExcecuteNonQuery command.
Any help is greatly appreciated!!

EDIT: I have reformatted to include parameters, still does not work does anyone have any ideas on what I am doing wrong?

foreach (DataRow fieldtable in setofTables.Tables[0].Rows)
{

    //do work                   
    table_name = fieldtable["table_name"].ToString().Trim();
    field_name = fieldtable["field_name"].ToString().Trim();

    MessageBox.Show(table_name + field_name);

    //create parameters

    OracleParameter fieldParamater = new OracleParameter("field_name", OracleDbType.Varchar2);
    OracleParameter diffParameter = new OracleParameter("mark_diff_oracle", OracleDbType.BinaryFloat);
    OracleParameter wellIdParameter = new OracleParameter("id", OracleDbType.Char);
    //wellIdParameter.Size = 10;

    //create oracle connection and open 
    OracleConnection OrclCon2 = new OracleConnection("Data Source=" + dbname + "; User Id=" + userid + ";Password=" + password1 + ";");
    OrclCon2.Open();

    //prepare sql to be passed to oracle 
    string UpdateOraSQL = "UPDATE " +table_name+ " set :field_name = :field_name - (:mark_diff_oracle) where  id = ':id' and :field_name is not null;";
    MessageBox.Show(UpdateOraSQL);   



    //create dommand
    OracleCommand UpdateDB = new OracleCommand(UpdateOraSQL, OrclCon2);
    UpdateDB.CommandType = CommandType.Text;
    //add parameters
    UpdateDB.Parameters.Clear();
    UpdateDB.Prepare();
    UpdateDB.Parameters.Add(fieldParamater).Value = field_name;
    UpdateDB.Parameters.Add(diffParameter).Value = mark_diff_oracle;
    UpdateDB.Parameters.Add(wellIdParameter).Value = id;
  • 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-17T16:52:16+00:00Added an answer on June 17, 2026 at 4:52 pm

    Remove the semicolon from the end of the sql statement. Change the following code

    string UpdateOraSQL = "UPDATE " +table_name+ " set :field_name = :field_name - (:mark_diff_oracle) where  id = ':id' and :field_name is not null;";
    

    to

    string UpdateOraSQL = "UPDATE " +table_name+ " set :field_name = :field_name - (:mark_diff_oracle) where  id = ':id' and :field_name is not null";
    

    See the following link for more information

    why the semicolon couldn't place in the CommandText of a OracleCommand when C#

    If the problem is still not resolved, it might be helpful if you post the entire exception message also.

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

Sidebar

Related Questions

I am trying to evaluate two dynamically assigned variables; then attempting to assign a
I have an image loader that I am attempting to resize dynamically. I would
I'm attempting to dynamically create a button control for each image I have in
I'm attempting to create a listview that binds dynamically to a set of dates.
I'm attempting to dynamically add both columns and rows to a TableLayoutPanel. I have
I'm attempting to have a UITableView that I can dynamically add and remove rows
I am attempting to create a program with a set of dynamically loaded layout
I am attempting to Dynamically update a MySql table, the $query looks correct when
Am attempting to dynamically create html which then injects itself as an iframe into
I'm attempting to dynamically use a value in an array within an object. In

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.