C # Query Database issues: Min (1) must is less than or equal to Max ( -1) in Range object

Source: Internet
Author: User
Tags database issues

The problem was caused by his carelessness, when it was fixed to the code, but there was no clue at all, knowing that I had found a problem in the realization.

Here's the code for the error:

datarow[] Tmpdrlist = TMPDT. Select (String. Format ("UserGroup = {0}", dr["UserGroup"]. ToString ()));

The above code does not have any grammatical problems, only when the problem occurs at the time of operation, then the best solution, and finally from the business implementation found that the database field UserGroup is a string, this is the reason, the code after the change is as follows:

datarow[] Tmpdrlist = TMPDT. Select (String. Format ("usergroup = ' {0} '", dr["UserGroup"]. ToString ()));

This is the single quotation mark question, this kind of question is really very silent.


Summarize:

1. If compile without error, but run the times wrong, then generally is the business implementation is incorrect or other features, so this time you need to check the business and logical implementation, not grammatical errors.

2. How to improve this detail is a more important issue, which is a bit of a waste of time.

This article from the "more efforts, the more fortunate" blog, declined reprint!

C # Query Database issues: Min (1) must is less than or equal to Max ( -1) in Range object

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.