Description of SQL statement parameters in C #

Source: Internet
Author: User
Tags oracleconnection

OracleConnection oc = new OracleConnection ("data source = osserver; User Id = *****; password = **");
OracleCommand cmd = new OracleCommand ("insert into cym1.previusfile (filename, filecontent) values (: filename,: filecontent)", oc );
OracleParameter op1 = new OracleParameter ("filename", OracleType. VarChar, 256 );
OracleParameter op2 = new OracleParameter ("filecontent", OracleType. Blob, filedata. Length );
Op1.Value = System. IO. Path. GetFileName (File1.Value );
Cmd. Parameters. Add (op1 );
Op2.Value = filedata;
Cmd. Parameters. Add (op2 );
Oc. Open ();
Cmd. ExecuteNonQuery ();
Oc. Close ();
In ORACLE, the SQL statement parameter is: + Parameter Name,
Insert into cym1.previusfile (filename, filecontent) values (: Filename,: Filecontent)
You do not need to write the parameter name in the parameter variable that defines this parameter:
OracleParameter op1 = new OracleParameter ("Filename", OracleType. VarChar, 256 );
SqlConnection conn = new SqlConnection ("data source = ccserver; user id = sa; password = ***; initial catalog = cym1 ");
SqlCommand cmd = new SqlCommand ("insert into previusfile (filename) values (@ filename)", conn );
SqlParameter sp = new SqlParameter ("@ filename", SqlDbType. VarChar, 256 );
Sp. Value = "1.jpg ";
Conn. Open ();
Cmd. ExecuteNonQuery ();
Conn. Close ();
In SQLSERVER, the SQL statement parameter is @ +,
Insert into previusfile (filename) values (@ filename)
In the parameter variable that defines this parameter, the parameter must be written @
SqlParameter sp = new SqlParameter ("@ filename", SqlDbType. VarChar, 256 );

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.