实例3 查询数据

执行查询时,可以使用 limit 子句限制查询的数量,一次请求最多可以查询 10000条数据,若不使用 limit 指定查询的数量,则默认查询1000条数据。

  • 查询1
  1. string connStr = "server=127.0.0.1;port=8105;username=sa;password=pinusdb";
  2. using (PDBConnection conn = new PDBConnection(connStr))
  3. {
  4. conn.Open();
  5. PDBCommand cmd = conn.CreateCommand();
  6. DataTable data = cmd.ExecuteQuery("select * from tab01 where devid = 101");
  7. }
  • 查询2
  1. string connStr = "server=127.0.0.1;port=8105;username=sa;password=pinusdb";
  2. using (PDBConnection conn = new PDBConnection(connStr))
  3. {
  4. conn.Open();
  5. PDBCommand cmd = conn.CreateCommand();
  6. PDBParameter[] queryParam = { new PDBParameter("@devid", PDBType.BigInt) };
  7. queryParam[0].Value = 101;
  8. DataTable data = cmd.ExecuteQuery("select * from tab01 where devid = @devid");
  9. }