Condition. Append ("and chinesename like @name");p. ADD ("@name" " % " " % ", System.Data.DbType.String);
Like can also parameterize queries.
@a The parameter notation of MSSQL
: A parameter notation for Oracle
? Parameter notation for OLE DB
In Access * indicates fuzzy matching
Mssql/oracle in% indicates fuzzy matching
Access 2000 is used for "Provider=Microsoft.Jet.OLEDB.4.0" in the default OLE DB connection for the source, which does not support the Replace function.
The Dapper is a lightweight ORM that can be conveniently used in. NET projects.
Conn. Query<users> ("SELECT * from the Users WHERE ID in @ids", new {ids = new string[] {"A", "B"}}). ToList (); So you can reach the target of in-parameterized queries. Conn. Querysingle<string> ("Select Count (*) from the Users where str like @a", new {a = "%bx%"}, Tran);
using(IDbConnection conn =NewSqlConnection ("Data Source=.;i Nitial catalog=test;integrated security=true") {Conn. Open (); using(IDbTransaction tran =Conn. BeginTransaction ()) {Conn. Execute ("Update table1 set ic= ' 1 ' where [email protected]",New{a ="123"}, Tran); Conn. Execute ("update table2 set ic= ' 3 ' where [email protected]",New{a ="1234"}, Tran); Tran.commit (); }}
This is an example of invoking a transaction using Dapper.
Go [Dapper] SQL Experience Set