This is a migrated thread and some comments may be shown as answers.
stored proc with varbinary(20) gets mapped to single byte
2 Answers 16 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Adam
Top achievements
Rank 1
Adam asked on 02 Dec 2009, 11:54 PM
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 Answers, 1 is accepted

Sort by
0
Adam
Top achievements
Rank 1
answered on 03 Dec 2009, 12:00 AM
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>

0
PetarP
Telerik team
answered on 03 Dec 2009, 08:14 AM
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.
Tags
General Discussions
Asked by
Adam
Top achievements
Rank 1
Answers by
Adam
Top achievements
Rank 1
PetarP
Telerik team
Share this question
or