Solved

Change the SelectCommand of the SqlDataSource

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

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.
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
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.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

809 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