Solved

Change the SelectCommand of the SqlDataSource

Posted on 2008-10-01
2
1,357 Views
Last Modified: 2013-12-18
I have the following code:

    protected void UltraWebGrid1_DataBinding(object sender, EventArgs e)
    {
        String sql = "Select * from VW_ADJUSTMENT_REASONS_MAP where trading_book='" + DropDownList1.SelectedValue.ToString() + "'";
        SqlDataSource1.SelectCommand = sql;
    }

When I trap the first statement and plug in what is returned from the variable sql into Oracle, I get results.  However, in this code, I get the following:



[OracleException (0x80131938): ORA-01036: illegal variable name/number
]
   System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle errorHandle, Int32 rc) +167
   System.Data.OracleClient.OracleParameterBinding.Bind(OciStatementHandle statementHandle, NativeBuffer parameterBuffer, OracleConnection connection, Boolean& mustRelease, SafeHandle& handleToBind) +1166
   System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle statementHandle, CommandBehavior behavior, Boolean needRowid, OciRowidDescriptor& rowidDescriptor, ArrayList& resultParameterOrdinals) +1604
   System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle statementHandle, CommandBehavior behavior, ArrayList& resultParameterOrdinals) +50
   System.Data.OracleClient.OracleCommand.ExecuteReader(CommandBehavior behavior) +174
   System.Data.OracleClient.OracleCommand.ExecuteDbDataReader(CommandBehavior behavior) +29
   System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +32
   System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +183
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +307
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +152
   System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +2868
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +84
   Infragistics.WebUI.UltraWebGrid.UltraWebGrid.DataBind() +1087
   Infragistics.WebUI.UltraWebGrid.UltraWebGrid.LoadPostData(String postDataKey, NameValueCollection values) +4722
   System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +898
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2548

Thanks

0
Comment
Question by:techhound
2 Comments
 
LVL 22

Accepted Solution

by:
Ivo Stoykov earned 500 total points
ID: 22617754
Hello techhound,

The error message says
ORA-01036:      illegal variable name/number
Cause:      Unable to find bind context on user side
Action:      Make sure that the variable being bound is in the sql statement.

you should do something lie the code bellow

HTH

I
protected void UltraWebGrid1_DataBinding(object sender, EventArgs e)

{

  String sql = "Select * from VW_ADJUSTMENT_REASONS_MAP where trading_book=:p1";

  OracleCommand cmd = new OracleCommand(sql, cn /*your connection object here*/);

  cmd.Parameters.Add(":p1", DropDownList1.SelectedValue.ToString());

  cmd.Parameters[0].Direction = ParameterDirection.Input;

  SqlDataSource1.SelectCommand = sql;

}

Open in new window

0
 

Author Closing Comment

by:techhound
ID: 31502059
Thanks
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now