4种连接方式异同比较

如:myCommand.CommandText = "SELECT CustomerID, CompanyName FROM Customers WHERE Country = @Country AND City = @City";OracleCommand.Parameters中的參數變量要在前面加“:”如:myCommand.CommandText = "UPDATE test SET test1 =:test1, test2 =:test2 WHERE id = :id";OleDbCommand 或 OdbcCommand 为“?”
如:myCommand.CommandText = "SELECT CustomerID, CompanyName FROM Customers WHERE Country = ? AND City = ?";

所以,需要注意:

OracleCommand oCmd = new OracleCommand();

oCmd.CommandText = "SELECT * FROM table WHERE Col = :Col ORDER BY Col2";

oCmd.Parameters.Add("Col",col);

而连接SQLServer:

SqlCommand sqlCmd = new SqlCommand();

sqlCmd .CommandText = "SELECT * FROM table WHERE Col = @Col ORDER BY Col2";

sqlCmd .Parameters.Add("@Col",col);

相关文章:

  • 2021-05-29
  • 2022-03-05
  • 2021-08-25
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2021-07-16
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-25
  • 2022-12-23
  • 2022-12-23
  • 2021-11-15
相关资源
相似解决方案