?
Solved

Change the SelectCommand of the SqlDataSource

Posted on 2008-10-01
2
Medium Priority
?
1,375 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 22

Accepted Solution

by:
Ivo Stoykov earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Suggested Courses

771 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