Note the type of int problem when inserting a database in insert

Source: Internet
Author: User

For example, a statement, insert into mbproduct (P_USERID,P_BIGID,P_QQ) VALUES ("+getuserid+", "+getdrpdl+" ', "+qq+",, ' "+bb+") (GetUserID is obtained from the primary key, there must be a value, you can write this), if so, suppose that QQ is obtained from the text box, if it is this form:

String Qq=txtqq.text, which occurs when TXTQQ is empty, has no value, that is, insert into mbproduct (P_USERID,P_BIGID,P_QQ) VALUES (1, ' + ', ' AA '), apparently, Syntax error, so, FIX:

Either the SQL statement in QQ, plus single quotation marks, to represent the string, you can convert int type, but not rigorous, or int qq=txtqq.text== ""? 0:int.parse (Txtqq.text), after the type to be judged

Note the type of int problem when inserting a database in insert

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.