none
Error on DataTable.Select: Min (64) must be less than or equal to max (-1) in a Range object. RRS feed

  • Question

  • Hi Friends

    currently i am under going one critical issue. Its a VB.net 2.0

    I have a code as follows, which is working since from long time but suddenly it start giving me error (Min (64) must be less than or equal to max (-1) in a Range object.).

    drHeaderInfo = dsList.Tables(2).Select(

    "ID = " & sID.Trim())

    In the above line of code, ID column in Table(2) is of string and sID is a variable is of string. the above code were working fine from long time. What i notice here is when the data length of sID variable is greather than 5 character then it throws the above mentioned error. and if sID has less than 5 characters then it works fine. Moreover, if i put sID variable value in single quote (

    drHeaderInfo = dsList.Tables(2).Select("ID = '" & sID.Trim() &"'" ) then if sID has more than 5 characters it works...

    Any help will be appriciated.

     

    • Moved by KJian_ Monday, December 20, 2010 3:06 AM (From:Transact-SQL)
    Friday, December 17, 2010 6:17 PM

Answers

  •  Hi contactme,

    Welcome to MSDN forums.

    According to your description, I think your problem relates to DataColumn.Expression.

    I quote some content from this link to explain your problem( http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx ) pay attention to "Expression Syntax" and "User-Defined Values".

    @String values should be enclosed within single quotation marks (and each single quotation character in a string value has to be escaped by prepending it with another single quotation character).

    So "ID = " & sID.Trim() is wrong, you should use "ID = '" & sID.Trim() &"'" instead.

     

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

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, December 20, 2010 8:52 AM
    Moderator

All replies

  • > currently i am under going one critical issue. Its a VB.net 2.0

    But this forum is for Transact-SQL - If you think you should look up a forum for Visual Basic.


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
    Links for SQL Server Books Online: SQL 2008, SQL 2005 and  SQL 2000.
    (Just click the link you need.)
    Friday, December 17, 2010 10:59 PM
  •  Hi contactme,

    Welcome to MSDN forums.

    According to your description, I think your problem relates to DataColumn.Expression.

    I quote some content from this link to explain your problem( http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx ) pay attention to "Expression Syntax" and "User-Defined Values".

    @String values should be enclosed within single quotation marks (and each single quotation character in a string value has to be escaped by prepending it with another single quotation character).

    So "ID = " & sID.Trim() is wrong, you should use "ID = '" & sID.Trim() &"'" instead.

     

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

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, December 20, 2010 8:52 AM
    Moderator
  • Hi contactme,

    I am writing to check the status of the issue on your side.  Would you mind letting us know the result of the suggestions? 
     
    If you need further assistance, please feel free to let me know.   I will be more than happy to be of assistance.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, December 27, 2010 2:20 AM
    Moderator