C # SQL uses a string variable in a where query statement with an INT type variable

Source: Internet
Author: User

When using the where statement to access the database, the where statement is queried using the variables defined above and above.

String sql3 = String. Format ("Update Ships set containernum= '" +list1[0]. containernum+ "' Where Name= '" +list[0]. Shipname+ "'");

Ships is the table name Containernum is the field name in the table

List1[0]. Containernum is an int type variable above, list[0]. ShipName is the string type variable above

You only need to manipulate the variables within the double quotation marks of the SQL statement, i.e.

("SELECT * from table name  where field name = '" + Variable name + "'    ") Note: ' + variable name + '  to enclose two double quotes in two single quotes

C # SQL uses a string variable in a where query statement with an INT type variable

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.