Solved

Change the SelectCommand of the SqlDataSource

Posted on 2008-10-01
2
1,355 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
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…
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

747 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

10 Experts available now in Live!

Get 1:1 Help Now