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