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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:23:56+00:00 2026-05-27T12:23:56+00:00

I am trying to implement prepared staments in my code as a way of

  • 0

I am trying to implement prepared staments in my code as a way of adding parameters to sql commands that are retrieved from a table held in any generic server. I cannot seem to get it right. I get the following error:

ORA-00936: missing expression
ORA-00936: missing expression

Prepare Statement: select VALUE from RWOL_CONFIGURATION where ID = @ItemId

My guess is that it just isn’t replacing the value but I dont know what I am missing.

I am trying the following to achieve the desired result. I create my object, get a query string out of our table in the database, add that to the command, add parameters to a list object and then use the final method shown below to tie it all together and run the query:

//This function gets me a config item from the database
private string GetConfigurationItem(string itemId)
    {
        //new database connection object
        OleDataBaseConnection oleDataBaseConnection = new OleDataBaseConnection();

        //todo get this query from the sql factory
        SqlFactory sqlFactory = new SqlFactory();

        //This method gets the query string from the database
        string sqlQuery = sqlFactory.GetQueryString("GET_CONFIGURATION_ITEM", m_dialect);

        if (!String.IsNullOrEmpty(sqlQuery))
        {
            //add parameter to list
            oleDataBaseConnection.AddStoredProcedureParameter("@ItemId", itemId);

            //execute the sql command after adding the parameters to the command 
            oleDataBaseConnection.OleExecutePrepareStatementWithParametersQuery(sqlQuery);

            string returnValue = oleDataBaseConnection.NextRecord() ? oleDataBaseConnection.GetFieldById(0) : "Error";

            oleDataBaseConnection.Close();

            return returnValue;
        }
        else
        {
            return "ERROR";
        }

    }

//adds the parameters to list objects ready for the next method
 public void AddParameter(string parameter, object value)
    {
        m_parameterName.Add(parameter);
        m_parameterValue.Add(value);
    } // End of void AddParameter()

    /// <summary>
    /// Executes a command with the parameters passed to AddParameter(parameterName, parameterValue) and creates a recordset.
    /// </summary>
    /// 
    /// <param name="commandName">The name of the stored procedure to execute.</param>
    public bool OleExecutePrepareStatementWithParametersQuery(string commandName)
    {
        if (String.IsNullOrEmpty(commandName))
        {
            return false;
        }

        try
        {
            PrepareConnection();

            m_oleDatabaseCommand.CommandText = commandName;
            m_oleDatabaseCommand.CommandType = CommandType.StoredProcedure;

            if (m_storedProcedureParameterName.Count != 0)
            {
                for (int i = 0; i < m_storedProcedureParameterName.Count; i++)
                {
                    m_oleDatabaseCommand.Parameters.AddWithValue(m_storedProcedureParameterName[i], m_storedProcedureParameterValue[i]);
                }

                m_storedProcedureParameterName.Clear();
                m_storedProcedureParameterValue.Clear();
            }

            m_hasRecordSet = true;

            m_oleDatabaseDataReader = m_oleDatabaseCommand.ExecuteReader();

            return true;
        }
        catch (Exception ex)
        {
            if (QueueErrors)
            {
                QueuedErrorsList.AppendLine(ex.Message);
                QueuedErrorsList.AppendLine("Prepare Statement: " + storedProcedureName);
                QueuedErrorsList.AppendLine();

                QueuedErrorCount++;

                return false;
            }

            try
            {
                Close();
            }
            catch
            {
            }

            throw new Exception(ex.Message + "\r\n\r\nPrepare Statement: " + storedProcedureName);
        }
    } // End of void OleExecutePrepareStatementWithParametersQuery()

Sorry if there is a lot of code but it is fairly straightforward and I thought it would help with the problem.

Is there anything obvious that would stop this from working?

  • 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-27T12:23:57+00:00Added an answer on May 27, 2026 at 12:23 pm

    The problem is that the OleDB provider does not support named parameters in the query.

    This:

    select VALUE from RWOL_CONFIGURATION where ID = @ItemId
    

    Should be:

    select VALUE from RWOL_CONFIGURATION where ID = ?
    

    See OleDbParameter on MSDN for examples.

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

Sidebar

Related Questions

Am trying to implement a generic way for reading sections from a config file.
Trying to implement the decorator pattern in C# from the code in the Head
SetFocus I'm trying implement the above Se Focus code in a Class Library that
I am trying to implement an update statement using a prepared statement in a
when trying to implement an Aspect, that is responsible for catching and logging a
Found a really nice code for Accordion nav and am trying implement on our
Trying to implement simple error handling without adding buku try / except statements to
I am trying to implement sql LIKE qualifier with placeholders for a set of
I am trying implement Unblock me Puzzle. i want to change image position from
I'm trying implement Data Annotation to my Linq to SQL objects. The .dbml file

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.