C # Programming: Parameter Issues for the SQLCOMMAND.PARAMETERS.ADD () method.

Source: Internet
Author: User

Add 2 parameters to a stored procedure

SQL Statement Example: "Update [tablename] username = @username where [email protected]"

And then put the needed

Command. Parameters.Add (New SqlParameter ("@id", sqldbtype.varchar,50));
Cmd. Parameters.Add ("@username", Textusername.text);

The standard System.Data.SqlClient
That's the way.

Parameter must be added one at a

It's written by itself. You can add a new parameters array to the form.

"@username": variable names in SQL statements
SqlDbType.VarChar Variable Type
50 Type of size:

As a parameter passed into execution, so as to effectively avoid some injected attacks

Supplement://
//
Command. Parameters.Add (New SqlParameter ("@id", sqldbtype.varchar,50));
Prototype
Public SqlParameter Add (SqlParameter value);

Cmd. Parameters.Add ("@username", Textusername.text);
Prototype
Public SqlParameter Add (string parametername, object value);
Public SqlParameter Add (string parametername, SqlDbType SqlDbType);
Public SqlParameter Add (string parametername, SqlDbType sqldbtype, int size);
Public SqlParameter Add (string parametername, SqlDbType sqldbtype, int size, string sourcecolumn);

The first sentence in several overloaded code is the first, the second sentence is the second.

C # Programming: Parameter Issues for the SQLCOMMAND.PARAMETERS.ADD () method.

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.