ExecuteScalar return value problem

Source: Internet
Author: User
Dbcommand.executescalar method:            Executes the query and returns the first column of the first row in the result set returned by the query. All other columns rows will be ignored.            return value: Type: System.Object.            if the first column of the first row in the result set is not found, a null reference is returned. If the value in the database is NULL, this query returns DBNull.Value.            for SELECT statements that use functions, such as select sum (a field) from table A, if no value exists, the return value of the Dbcommand.exceutescalar method is DBNull.Value, and the            caller needs to use the Result is DBNull or result = = DBNull.Value to judge.            for the caller of the Dbcommand.executescalar method of ADO, be careful to choose whether to use result = = NULL based on the SQL statement being used             or to use result is DBNull to determine if the query result is empty.            if you use result = = NULL | | Result is DBNull to determine whether the query result is empty is more insurance,            can adapt to the two kinds of SQL statements, but the efficiency of the operation will be reduced.

ExecuteScalar return value problem

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.