About the differences between Oracle and SQL Server database splicing database statements in. Net

Source: Internet
Author: User

1  stringsql ="INSERT INTO Personinfo"+2 "(Id,employeename,employeecode,"+3 "VALUES (: Id,:employeename,:employeecode,")";4Oracleparameter[] Pars = {NewOracleParameter ("ID", t.id),5                                        NewOracleParameter (": EmployeeName", T.employeename),6                                        NewOracleParameter (": Employeecode", T.employeecode)7                                       };8  returnOracledbhelper.executesql (SQL, CommandType.Text, pars);
View Code
 1 StringBuilder strsql=new StringBuilder (); 2 Strsql.append ("INSERT INTO Books ("); 3 Strsql.append ("Title,author,publisherid)"); 4 Strsql.append ("values"); 5 Strsql.append ("@Title, @Author, @PublisherId)"); 6 Strsql.append ("; select @ @IDENTITY");                     7 sqlparameter[] Parameters = {8 new SqlParameter ("@Title", sqldbtype.nvarchar,200), 9 New SqlParameter ("@Author", sqldbtype.nvarchar,200), ten new SqlParameter ("@PublisherI D ", sqldbtype.int,4)};11 parameters[0]. Value = model. Title;12 Parameters[1]. Value = model. Author;13 parameters[2]. Value = model.  Publisher.id Object obj = Dbhelpersql.getsingle (strsql.tostring (), parameters);                 (obj = = null) 1;19}20 ELSE21 {22 Return Convert.ToInt32(obj); 23} 
View Code

In an Oracle database, parameter substitution cannot use "@", to use ":"

About the differences between Oracle and SQL Server database splicing database statements in. Net

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.