none
Linq to Sql stored proc Length cannot be less than zero.Parameter name: length RRS feed

  • Question

  • Hi,

     I keep getting this wiered error when Im calling a stored procedure using linq. Its driving me insane as also cant seem to debug into it to see whats happening ?

    Any Ideas

     Please See below for code

    TIA

    STU

     

    class

     

    clsContextMemberLatestImages:DataContext

    {

     

     

    public clsContextMemberLatestImages(System.Data.IDbConnection Connection)

     

    base(Connection)

     

    Function(Name = "myStoredProc", IsComposable = false)]

     

    public ISingleResult<clsMemberLatestImagesEntity> getMemberLatestImages

     

    Parameter(Name = "@p_nIdRegister", DbType = "bigint")] Int64 p_nIdRegister)

     

    this.Log = new DebugTextWriter();

     

    IExecuteResult objResult = this.ExecuteMethodCall(this, (MethodInfo)(MethodInfo.GetCurrentMethod()), p_nIdRegister);

     

    ISingleResult<clsMemberLatestImagesEntity> objResults = (ISingleResult<clsMemberLatestImagesEntity>)objResult.ReturnValue;

     

    return objResults;

     

     

    using

     

    System.Data.Linq.Mapping;

    using

     

    System;

     

    Table(Name = "memberLatestImages")]

    public

     

    class clsMemberLatestImagesEntity

    {

     

    private Int64 _IdRegister;

     

    private String _AdvImageFile;

     

    private String _ImageDesc;

     

    private String _ImageUser;

     

    Column(DbType = "bigint")]

     

    public Int64 IdRegister

     

    set { _IdRegister = value; }

     

    get { return _IdRegister; }

     

    Column(DbType = "varchar(25)")]

     

    public String AdvImageFile

     

    set { _AdvImageFile = value; }

     

    get { return _AdvImageFile; }

     

    Column(DbType = "varchar(50")]

     

    public String ImageDesc

     

    set { _ImageDesc = value; }

     

    get { return _ImageDesc; }

     

    Column(DbType = "varchar(50)")]

     

    public String ImageUser

     

    set { _ImageUser = value; }

     

    get { return _ImageUser; }

     

     

     

    }

    }

     

     

     

     

    {

     

     

     

     

    }

    [

     

     

     

    {

     

     

     

     

    }

    [

     

     

     

    {

     

     

     

     

    }

    [

     

     

     

    {

     

     

     

     

     

    [

     

     

     

     

     

     

     

    [

     

    }

    }

     

     

     

     

     

     

     

    {

     

     

     

    ([

     

     

     

    { }

    [

     

    heres the stack trace

     

      StackTrace "   at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)\r\n   at System.Data.Linq.SqlClient.SqlTypeSystem.ProviderBase.Parse(String stype)\r\n   at System.Data.Linq.SqlClient.Translator.BuildProjectionInternal(SqlExpression item, MetaType rowType, IEnumerable`1 members, Boolean allowDeferred, SqlLink link, Expression source)\r\n   at System.Data.Linq.SqlClient.Translator.BuildProjection(SqlExpression item, MetaType rowType, Boolean allowDeferred, SqlLink link, Expression source)\r\n   at System.Data.Linq.SqlClient.QueryConverter.TranslateStoredProcedureCall(MethodCallExpression mce, MetaFunction function)\r\n   at System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node)\r\n   at System.Data.Linq.SqlClient.QueryConverter.ConvertOuter(Expression node)\r\n   at System.Data.Linq.SqlClient.SqlProvider.BuildQuery(Expression query, SqlNodeAnnotations annotations)\r\n   at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)\r\n   at System.Data.Linq.DataContext.ExecuteMethodCall(Object instance, MethodInfo methodInfo, Object[] parameters)\r\n   at clsContextMemberLatestImages.getMemberLatestImages(Int64 p_nIdRegister) in E:\\web\\FreeDate\\MLServiceDA\\DataContext\\clsContextMemberLatestImages.cs:line 22\r\n   at MLServiceDA.commonDA.getLatestMembersImages(Int64 p_nIdRegister) in E:\\web\\FreeDate\\MLServiceDA\\DataAccess\\commonDA.cs:line 203" string

    Wednesday, April 21, 2010 1:13 PM

Answers

All replies

  • Hello,

     

    Welcome to MSDN forums!

     

    Based on the code snippet you posted, I don’t find any obvious problems.   If it is convenient for you, could you please send me a demo project and db file for further investigation?   My mail address is v-micsun@microsoft.com.   Thanks a lot.   

     

    Have a nice day!

     

     

    Best Regards,
    Lingzhi Sun

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com

     

    BTW, I think the problem is for LINQ to SQL instead of Entity Framework, so I will move this thread to LINQ to SQL forum.  


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Thursday, April 22, 2010 2:38 AM
    Moderator
  • Hi,

     

    I sent you the code. Have you had chance to look at this yet at all please ?

     

    Thanks

     

    Stu

    Sunday, April 25, 2010 6:21 PM
  • Hello Stu,

     

    Sorry for the delay!  I am on annual leave last Friday.  I will research the case today and get back to you as soon as possible.

     

    Have a nice day!

     

     

    Best Regards,
    Lingzhi Sun

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, April 26, 2010 2:19 AM
    Moderator
  • Hello Stu,

     

    After several hours debugging, I finally find the root cause.  There seems to be some typo in DbType value of the column mapping.  I have send you a mail.   

    If you have any questions, please feel free to let me know.

     

    Have a nice day!

     

     

    Best Regards,
    Lingzhi Sun

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, April 27, 2010 9:27 AM
    Moderator