Print Page | Close Window

Parameter Passing in PassthruRdbQuery

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=507
Printed Date: 11-Jun-2026 at 4:35pm


Topic: Parameter Passing in PassthruRdbQuery
Posted By: Customer
Subject: Parameter Passing in PassthruRdbQuery
Date Posted: 17-Oct-2007 at 1:06pm

When we use 3-tier deployment and the client executes a PassthruRdbQuery with parameters like

select * from "DB_ADM"."DB_PERSONS" where ((id <> 0) and (upper("DB_ADM"."DB_PERSONS"."LAST_NAME") like upper(:v0))) and (ROWNUM <= 500) Params: :v0=Anacker1%,

we get the following error:

"Type 'Oracle.DataAccess.Client.OracleParameter' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute."

How should we avoid this error? This problem is rather urgent.




Replies:
Posted By: IdeaBlade
Date Posted: 17-Oct-2007 at 1:09pm

I believe you’re using a DbParameter typed parameter in the PassthruRdbQuery.  You must use the RdbParameter type via ParameterizedSql instead for remoting PassthruRdbQuery.  See RdbParameter’s help:

 

  /// <remarks>

  /// An <b>RdbParameter</b> is essentially a <see cref="DbParameter"/> that is marshalled by

  /// value rather by reference when passed to a remote Business Object Server.  The remoting channel

  /// used by the client does not allow two-way communication with the remote server, which a

  /// DbParameter as a MarshalByRefObject requires.

  /// <para>

  /// Use an <b>RdbParameter</b> when adding parameters to a <b>StoredProcRdbQuery</b> or

  /// <b>PassthruRdbQuery</b>.

  /// </para>

  /// </remarks>

 

Try this for your query and see if it works.

 

      RdbKey key = (RdbKey)mPm.GetDataSourceKey(typeof(DB_PERSONS));

 

      string lastName = "LAST_NAME";

      string parmName = key.AdoHelper.FormatParameterName(lastName);

      RdbParameter param = new RdbParameter(parmName, DbType.String);

      param.Value = "Anacker1%";

 

      string select = String.Format(

        "select * from \"DB_ADM\".\"DB_PERSONS\"" +

        "  where ((id <> 0) and (upper({0}) like upper({1}))) and (ROWNUM <= 500)",

        lastName, parmName);

      ParameterizedSql sql = new ParameterizedSql(select, param);

      PassthruRdbQuery query = new PassthruRdbQuery(typeof(DB_PERSONS), sql);

 

Let us know the result. Thanks

 




Print Page | Close Window