Solved

Change the SelectCommand of the SqlDataSource

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
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.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

733 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