ORA-01008: not all variables bound

This was one of those “duh” error. I was attempting to retrieve data from Oracle using some simple ADO.NET code, like the code below, but I was receiving the error “ORA-01008: not all variables bound“.

string value = String.Empty;
using (OracleConnection conn = new OracleConnection(connString)) {
    using (OracleCommand comm = new OracleCommand("SELECT Description FROM ScottsTable WHERE ID = :id", conn)) {
        comm.CommandType = CommandType.StoredProcedure;
        comm.Parameters.Add(":id", OracleDbType.Varchar2, 40).Value = "scott";
        value = comm.ExecuteScalar().ToString();

The problem was I was setting the OracleCommand’s CommandType property to StoredProcedure when it was actually straight text. Removing this line resolved the error.



  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: