实例3 查询数据
执行查询时,可以使用 limit 子句限制查询的数量,一次请求最多可以查询 10000条数据,若不使用 limit 指定查询的数量,则默认查询1000条数据。
- 查询1
- string connStr = "server=127.0.0.1;port=8105;username=sa;password=pinusdb";
- using (PDBConnection conn = new PDBConnection(connStr))
- {
- conn.Open();
- PDBCommand cmd = conn.CreateCommand();
- DataTable data = cmd.ExecuteQuery("select * from tab01 where devid = 101");
- }
- 查询2
- string connStr = "server=127.0.0.1;port=8105;username=sa;password=pinusdb";
- using (PDBConnection conn = new PDBConnection(connStr))
- {
- conn.Open();
- PDBCommand cmd = conn.CreateCommand();
- PDBParameter[] queryParam = { new PDBParameter("@devid", PDBType.BigInt) };
- queryParam[0].Value = 101;
- DataTable data = cmd.ExecuteQuery("select * from tab01 where devid = @devid");
- }