stored proc with varbinary(20) gets mapped to single byte

Thread is closed for posting
3 posts, 0 answers
  1. Adam
    Adam  avatar
    30 posts
    Member since:
    Jun 2009

    Posted 02 Dec 2009 Link to this post

    I'm trying to reverse engineer a stored proc that takes a varbinary(20) as a parameter, but the code that gets generated has a single byte as a parameter to the method.
  2. Adam
    Adam  avatar
    30 posts
    Member since:
    Jun 2009

    Posted 02 Dec 2009 Link to this post

    If i manually change the stored proc generated code to byte[] I get this error:

    Telerik.OpenAccess.RT.sql.SQLException: Type not supported for setObject: -3
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.setObject(Int32 parameterIndex, Object x, Int32 targetSqlType, Int32 scale)
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.Telerik.OpenAccess.RT.sql.PreparedStatement.setObject(Int32 parameterIndex, Object x, Int32 targetSqlType)
       at OpenAccessRuntime.Relational.RelationalQueryResult.createFetchResult(Connection conParam, SqlDriver sqlDriver, Boolean scrollableParam, FetchSpec fetchSpec, RelationalCompiledQuery relationalCompiledQuery, RelationalStorageManager storageManager, Object[] paramVals, Int32 fetchSize, Int32 maxRows)

    the generated method looks like this:

      public static IQueryResult validateUser(IObjectScope scope,string uSER_NAME,byte pASSWORD)
            {
                IQuery query = scope.GetSqlQuery("AUTH.VALIDATE_USER ?,?",null,"VARCHAR USER_NAME,VARBINARY PASSWORD");
                
                IQueryResult res = query.Execute(new object[] {uSER_NAME,pASSWORD});
                int a = res.Count;//Actually executes the query
                
                return res;
            }
           
    the reversemapping.config looks like this:

     <procedure name="'AUTH'.'VALIDATE_USER'" method="validateUser">
                    <parameter name="@USER_NAME" mode="IN" adoType="12" sqlType="nvarchar" length="255" scale="0" isNull="True" />
                    <parameter name="@PASSWORD" mode="IN" adoType="-3" sqlType="varbinary" length="20" scale="0" isNull="True" />
                </procedure>

  3. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 03 Dec 2009 Link to this post

    Hello Adam ,

    Unfortunately the types varbinary and longvarbinary are not yet supported by Telerik OpenAccess ORM to be directly passed in the GetSqlMethod (note that to execute a stored procedure explicitly you must relay on the GetSqlMethod). The only workaround would be if it is possible for you to use the stored procedure implicitly. Internally we are doing some conversions that will suppress the problem until the problem you encountered is fixed.

    Kind regards,
    Petar
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top